Android ListView with Title -
i want add title bar in list view.
i have added text view inside listview can act title:
layout file :
<linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/layout_rounded" android:layout_marginright="10px" android:layout_marginleft="10px" android:layout_margintop="30px" android:layout_below="@id/linlaypay" android:orientation="vertical" android:padding="10dip" > <listview android:id="@+id/rectran" android:layout_width="match_parent" android:layout_height="wrap_content" > </listview> </linearlayout >
here code used add title listview dynamically:
listview = (listview) findviewbyid(r.id.rectran); textview textview = new textview(getapplicationcontext()); textview.settext("header view"); listview.addheaderview(textview);
the problem ,an emty text view isadded listview without text "header view". why?am missing anything?
i don't believe can add view this. view being passed listview needs inflated.
create header.xml layout file text view in text set.. , run code below.
layoutinflater inflater = getlayoutinflater(); viewgroup header = (viewgroup)inflater.inflate(r.layout.header, listview, false); listview.addheaderview(header, null, false);
Comments
Post a Comment