我有以下代码: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