0
我通過擴展ListActivity來填充列表。我已將列表添加到列表中以顯示列表中項目的總數。在ListActivity中爲TextView設置文本
我在一個單獨的佈局文件header.xml中維護了標題視圖,如下所示。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/headerTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Total number of devices :"
android:textSize="15dip"
android:layout_weight="1" />
</LinearLayout>
這是怎麼了增加頭部在ListViewActivity類名單,
ListView lv = getListView();
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false);
lv.addHeaderView(header, null, false);
如何設置頁眉的TextView的文本?我嘗試了以下,併爲TextView返回null。
TextView textBox = (TextView)findViewById(R.id.);
textBox.setText("Count");