我有以下代碼:Android的頁眉和頁腳不使用自定義的ListView出現
public class RefreshView extends ListView {
private LayoutInflater inflater;
private RelativeLayout mHeaderView;
private RelativeLayout mFooterView;
public RefreshView(Context context) {
super(context);
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Refresh view
mHeaderView = (RelativeLayout) inflater.inflate(R.layout.header, this,
true);
addHeaderView(mHeaderView);
mFooterView = (RelativeLayout) inflater.inflate(R.layout.footer, this,
false);
addFooterView(mFooterView, this, true);
}
}
,這是我的main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.merry.more.RefreshView
android:id="@+id/android:list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
</LinearLayout>
在我ListActivity
我把這個在OnCreate中:
mListItems = new LinkedList<String>();
mListItems.addAll(Arrays.asList(mStrings));
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mListItems);
setListAdapter(adapter);
我看到我所有的listitems,但沒有頁眉頁腳。有任何想法嗎? :○
我輸入「在我的ListActivity我打電話給oncreate:」 – Maurice 2011-12-15 09:55:58