Android - Why ListView inside ListView does not work? -
my xml file:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="" android:id="@+id/address" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="" android:layout_below="@+id/address" android:id="@+id/win_title" /> <listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/win_list" android:layout_below="@+id/win_title" android:layout_weight="1" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="" android:id="@+id/lose_title" /> <listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/lose_list" android:layout_weight="1" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="" android:id="@+id/cannot_compare_title" /> <listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/cannot_compare_list" android:layout_weight="1" /> </linearlayout>
and custom adapter:
public class analysisresultadapter extends arrayadapter<comparisonresult> { static class viewholder { textview address; textview win_title; listview win_list; textview lose_title; listview lose_list; textview cannot_compare_title; listview cannot_compare_list; } private hashtable<string, seveneleven[]> sevenelevendata; public analysisresultadapter(context context, int resource, list<comparisonresult> houses) { super(context, resource, houses); } public void setsevenelevendata(hashtable<string, seveneleven[]> sevenelevendata) { this.sevenelevendata = sevenelevendata; } @override public view getview(int position, view convertview, viewgroup parent) { view view = convertview; viewholder holder; if (view == null) { layoutinflater viewinflater; viewinflater = layoutinflater.from(getcontext()); view = viewinflater.inflate(r.layout.analysis_result_list_item, null); holder = new viewholder(); holder.address = (textview) view.findviewbyid(r.id.address); holder.win_title = (textview) view.findviewbyid(r.id.win_title); holder.win_list = (listview) view.findviewbyid(r.id.win_list); holder.lose_title = (textview) view.findviewbyid(r.id.lose_title); holder.lose_list = (listview) view.findviewbyid(r.id.lose_list); holder.cannot_compare_title = (textview) view.findviewbyid(r.id.cannot_compare_title); holder.cannot_compare_list = (listview) view.findviewbyid(r.id.cannot_compare_list); view.settag(holder); } else { holder = (viewholder) view.gettag(); } if (this.sevenelevendata.size() == 0) { return view; } comparisonresult result = getitem(position); holder.address.settext(result.house.address); if (result.win.size() > 0) { arraylist<string> storenames = new arraylist<string>(); (int storeindex : result.win) { storenames.add(this.sevenelevendata.get(result.house.area)[storeindex].storename); } holder.win_title.settext("win"); holder.win_list.setadapter(new arrayadapter<string>( getcontext(), r.layout.text_list, r.id.text_list, storenames )); } if (result.lose.size() > 0) { arraylist<string> storenames = new arraylist<string>(); (int storeindex : result.lose) { storenames.add(this.sevenelevendata.get(result.house.area)[storeindex].storename); } holder.lose_title.settext("lose"); holder.lose_list.setadapter(new arrayadapter<string>( getcontext(), r.layout.text_list, r.id.text_list, storenames )); } if (result.cannotbecompared.size() > 0) { arraylist<string> storenames = new arraylist<string>(); (int storeindex : result.cannotbecompared) { storenames.add(this.sevenelevendata.get(result.house.area)[storeindex].storename); } holder.cannot_compare_title.settext("cannotbecompared"); holder.cannot_compare_list.setadapter(new arrayadapter<string>( getcontext(), r.layout.text_list, r.id.text_list, storenames )); } return view; } }
the problem is: @+id/address textview shows text successfully, other things not shown. don't know why happened.
how can solve problem ? can me ?
thanks.
use scrollview intead of outer(parent) listview.
and use lisview inner listview.
it gives scrolling feature.
Comments
Post a Comment