当我想在列表视图下方显示页脚按钮时,我遇到了应用程序崩溃的问题。我附上了我的 xml 代码和活动代码。任何帮助将不胜感激。
ContactListActivity.java
public class ContactListActivity1 extends ListActivity {
static ArrayList<String> ids = new ArrayList<String>();
ListView lv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContactList1 contactList = this.getContacts();
ArrayAdapter<Contact1> adapter = new ContactAdapter1(this,
contactList.getContacts());
// LoadMore button
Button btnLoadMore = new Button(this);
btnLoadMore.setText("Load More");
View v = getLayoutInflater().inflate(R.layout.contactlistitem,null);
lv.addFooterView(btnLoadMore);
lv.setAdapter(adapter);
}
还有我的 XML 代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
>
<TextView
android:id="@+id/txtDisplayName"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="TextView"
>
</TextView>
<ImageView
android:id="@+id/contact_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:id="@+id/contactList1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/txtDisplayName"
/>
</LinearLayout>