In the following example we add a previous button in the header, next button in the footer.
Activity Code:
ListView list = getListView();
View headerView = View.inflate(this, R.layout.header, null);
list.addHeaderView(headerView);
View footerView = View.inflate(this, R.layout.footer, null);
list.addFooterView(footerView);
Header XML Layout - header.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"
android:padding="5dip">
<Button android:id="@+id/previous"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Footer XML Layout - footer.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"
android:padding="5dip">
<Button android:id="@+id/next"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>
I am getting force close error in this line mainListView.addHeaderView(headerView);
ReplyDeletePlz help me asap.
Thanks a lot.I got what i want exactly.
ReplyDelete+1 thanks alot work fine :)
ReplyDeletenice post, easiest one
ReplyDeleteCASINO HOTEL & CASINO HOTEL - Mapyro
ReplyDeleteHotels near CASINO HOTEL 김천 출장안마 & CASINO 안양 출장안마 HOTEL in Las Vegas Strip, 공주 출장샵 NV 89109 - Use this 정읍 출장안마 simple form to find hotels, motels, and 부산광역 출장샵 other lodging near CASINO HOTEL & CASINO HOTEL in