android - ExpandableListView custom design -
i want customize expandablelistview, can't customize childs. how can make border , fill background (example below src code)
what have:
expandablelistview
<expandablelistview android:id="@+id/explistviewservices" android:layout_width="match_parent" android:divider="@color/white" android:dividerheight="10dp" android:childdivider="@color/white" android:layout_height="match_parent" />
list_fragment_services_groups.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:paddingleft="50dp" android:background="@drawable/expandblelistview_background" android:paddingtop="10dp" android:paddingbottom="10dp" android:layout_height="wrap_content"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imgservicesgroup" android:src="@drawable/ic_internet" /> <textview android:layout_width="wrap_content" android:id="@+id/txtservicesgroup" android:textappearance="?android:attr/textappearancelarge" android:textcolor="@color/black" android:layout_torightof="@id/imgservicesgroup" android:paddingleft="15dp" android:textstyle="bold" android:layout_height="wrap_content" /> </relativelayout>
list_fragment_services_child.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_marginleft="40dp" android:background="@color/white" android:layout_height="wrap_content"> <textview android:layout_width="wrap_content" android:id="@+id/txtserviceschild" android:paddingleft="50dp" android:paddingtop="5dp" android:paddingbottom="5dp" android:textcolor="@color/black" android:layout_height="wrap_content" /> </relativelayout>
expandblelistview_background.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/lightgray" /> <corners android:radius="10dp"/> </shape>
what want:
add:
public class servicesadapter extends baseexpandablelistadapter { private static final string tag = servicesadapter.class.getsimplename(); private arraylist<hashmap<string, string>> group; arraylist<arraylist<hashmap<string, string>>> child; private context context; private static string group_name = "group_name"; private static string group_image = "group_image"; private static string child_name = "child_name"; public servicesadapter(context context, arraylist<hashmap<string, string>> group, arraylist<arraylist<hashmap<string, string>>> child) { this.context = context; this.group = group; this.child = child; } @override public int getgroupcount() { return group.size(); } @override public int getchildrencount(int groupposition) { return child.get(groupposition).size(); } @override public object getgroup(int groupposition) { return group.get(groupposition); } @override public object getchild(int groupposition, int childposition) { return child.get(groupposition).get(childposition); } @override public long getgroupid(int groupposition) { return groupposition; } @override public long getchildid(int groupposition, int childposition) { return childposition; } @override public boolean hasstableids() { return true; } @override public view getgroupview(int groupposition, boolean isexpanded, view convertview, viewgroup parent) { if (convertview == null) { layoutinflater infalinflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); convertview = infalinflater.inflate(r.layout.list_fragment_services_groups, null); } if (isexpanded) { convertview.setbackgroundresource(r.drawable.expandblelistview_background_selected); } else { convertview.setbackgroundresource(r.drawable.expandblelistview_background); } imageview imgservicesgroup = (imageview) convertview.findviewbyid(r.id.imgservicesgroup); textview txtservicesgroup = (textview) convertview.findviewbyid(r.id.txtservicesgroup); txtservicesgroup.settext(group.get(groupposition).get(group_name)); int imageid = context.getresources().getidentifier("ic_" + group.get(groupposition).get(group_image), "drawable", context.getpackagename()); imgservicesgroup.setimageresource(imageid); return convertview; } @override public view getchildview(int groupposition, int childposition, boolean islastchild, view convertview, viewgroup parent) { if (convertview == null) { layoutinflater infalinflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); convertview = infalinflater.inflate( r.layout.list_fragment_services_child, null); } textview txtserviceschild = (textview) convertview.findviewbyid(r.id.txtserviceschild); txtserviceschild.settext(child.get(groupposition).get(childposition).get(child_name)); return convertview; } @override public boolean ischildselectable(int groupposition, int childposition) { return false; } }
i think can set background expandablelistview
Comments
Post a Comment