java - ExpandableListView only showing one parent -
among other view
s, trying programmatically add expandablelistview
linearlayout
. this, using simpleexpandablelistadapter
. there supposed ten parent elements, each single child element. encased in onpostexecute
of asynctask
, if matters. here java:
arraylist<hashmap<string,string>> parentlist = new arraylist<>(); arraylist<arraylist<hashmap<string,string>>> childlist = new arraylist<>(); (int k = 0 ; k < 10 ; k++) { hashmap<string,string> parentmap = new hashmap<>(); parentmap.put("item", + ":" + k + "source"); parentlist.add(parentmap); arraylist<hashmap<string,string>> childitemlist = new arraylist<>(); hashmap<string,string> childmap = new hashmap<>(); childmap.put("item", + ":" + k + "data"); childitemlist.add(childmap); childlist.add(childitemlist); } /* build expandable list */ simpleexpandablelistadapter adapter = new simpleexpandablelistadapter( details, parentlist, r.layout.expandable_parent, new string[] {"item"}, new int[] {r.id.expandable_parent}, childlist, r.layout.expandable_child, new string[] {"item"}, new int[] {r.id.expandable_child} ); expandablelistview info = new expandablelistview(details); info.setadapter(adapter); layout.addview(info);
this expandable_parent.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <textview android:id="@+id/expandable_parent" android:paddingleft="30dp" android:paddingright="30dp" android:layout_width="match_parent" android:layout_height="wrap_content"/> </linearlayout>
and expandable_child.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <textview android:id="@+id/expandable_child" android:paddingleft="40dp" android:paddingright="40dp" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </linearlayout>
there may few mistakes in there, took simplified version of java. problem when run, first parent element shows up. click on , image on left flips, indicating group opened, no child elements displayed. what's problem?
Comments
Post a Comment