Google Playのマーケットとまったく同じように、折りたたみ可能なビューを実装したいと考えています。それは、コンテンツからいくつかの行と矢印を表示し、矢印をタップすると内容全体が表示されます。これはExpandableListViewで実装されていますか?Google Playのような折りたたみ可能なビューを実装するにはどうすればよいですか?
スクリーンショットは、私が探しているものを強調表示して添付されています。おかげさまで
Google Playのマーケットとまったく同じように、折りたたみ可能なビューを実装したいと考えています。それは、コンテンツからいくつかの行と矢印を表示し、矢印をタップすると内容全体が表示されます。これはExpandableListViewで実装されていますか?Google Playのような折りたたみ可能なビューを実装するにはどうすればよいですか?
スクリーンショットは、私が探しているものを強調表示して添付されています。おかげさまで
簡単な方法があります:
final TextView descriptionText = (TextView) view.findViewById(R.id.detail_description_content);
final TextView showAll = (TextView) view.findViewById(R.id.detail_read_all);
showAll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showAll.setVisibility(View.INVISIBLE);
descriptionText.setMaxLines(Integer.MAX_VALUE);
}
});
XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/detail_description_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/detail_description_content"
android:maxLines="5"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/detail_read_all"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
重要な部分はMAXLINESとscrollviewです。これは、遅いアニメーション(それはより複雑な入札になるだろうが)を即座に開く効果を与えるものではない。
それは素晴らしいです! –
素晴らしい男は、魅力のように動作します。 –
私の恐ろしい英語です。
Warpzip応答たちのlayoutInたちのレイアウトでは
res/values/strings.xml
...
...
<string name="str_more"><![CDATA[<p><b>This is the header</b><u>(see more ..)</u>]]></string>
<string name="str_less"><![CDATA[<p><b>This is the header</b><u>(less ..)</u>]]></string>
<string name="str_details"><![CDATA[<p>A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.</p>]]></string>
...
...
に基づいて、我々は垂直のLinearLayout(または少し仕事RelativeLayoutを持つ)とのscrollviewを含めることができます。これらには:
<TextView
android:id="@+id/txtvw_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/str_more"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtvw_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtvw_tituloEntreTodos"
android:text="@string/str_details"
android:textAppearance="?android:attr/textAppearanceMedium" />
最後に私たちの活動
view = inflater.inflate(R.layout.f_entretodos, container, false);
info = (TextView) view.findViewById(R.id.txtvw_header);
fullinfo = (TextView) view.findViewById(R.id.txtvw_detail);
info.setText(Html.fromHtml(getString(R.string.str_more)));
fullinfo.setText(Html.fromHtml(getString(R.string.str_detail)));
fullinfo.setVisibility(View.GONE);
info.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (fullinfo.isShown()){
fullinfo.setVisibility(View.GONE);
info.setText(Html.fromHtml(getString(R.string.str_more)));
}else{
fullinfo.setVisibility(View.VISIBLE);
info.setText(Html.fromHtml(getString(R.string.str_less)));
}
}
});
これは役立つかもしれない:http://stackoverflow.com/questions/5165682/how-to-implement-expandable-panels-in-android – 0gravity
はいこれは私が探しているものを実装するので、少し助けますが、私はそれがカスタムレイアウトよりも簡単な解決策であることを期待していました... –