添加ddHeaderView注意问题
<?xml version="1.0" encoding="utf-8"?>?
<LinearLayout ?xmlns:android="http://schemas.android.com/apk/res/android"?
? ? android:layout_width="fill_parent"
android:id=“@+id=header”?
??? android:layout_height="fill_parent" >?
? ? <Button ?
? ? ? ? android:id="@+id/testButton"?
? ? ? ? android:layout_width="fill_parent" ?
? ? ? ? android:layout_height="wrap_content"?
? ? ? ? android:text="Income" ?
? ? ? ? android:textSize="15dip"?
? ? ? ? android:layout_weight="1" />?
</LinearLayout>?
上面是head.xml
你如果ListView lv = getListView();?
lv.addHeaderView(findViewById(R.layout.header));?就错了
通常ListView lv = getListView();?
LayoutInflater inflater = getLayoutInflater();?
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false);?
lv.addHeaderView(header, null, false);?