我尝试编写此代码,但在页眉和页脚应该加载的部分出现错误。我从这篇文章 Android ListActivity - 固定页眉和页脚中得到了这个,我只是检查希望这不会导致人们错误代码...错误提示错误:在包'android'中找不到属性'above'的资源标识符错误:在包'android'中找不到属性'below'的资源标识符
或者我只是弄错了当我错的时候忽略它
In main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include
android:id="@+id/header_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/header.xml" />
<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:below="@id/header_layout"
android:above="@id/footer_layout" />
<include
android:id="@+id/footer_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/footer.xml" />
</RelativeLayout>
In header.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/header_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Application Title"/>
</LinearLayout>
In footer.xml`enter code here`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/done_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"/>
</LinearLayout>
在活动中,这里
public class MainActivity extends ListActivity {
private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mListView = (ListView) findViewById(R.id.list_view);
// Now you can do whatever you want
}
}