I have 2 layout .xml forms. One is header form and the other is to display the list. Using the header view I can display the header. When I tryed to click the button on the header form I cannot get the response. Please help me Here is my code.
//To display the Taskname as listview
ListView listView = getListView();
TextView HeaderUnametxt=(TextView) header.findViewById(R.id.UsernameHead);
TextView HeaderCnametxt=(TextView) header.findViewById(R.id.CompanynameHead);
String UName= bundle.getString("UserName");
String CName= bundle.getString("Company");
HeaderUnametxt.setText(UName); //To display the Usename on the header
HeaderCnametxt.setText(CName); //To display the Company Name on the header
listView.addHeaderView(header);
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.tasklist,
R.id.Tasklist, TaskNames));
header.xml file is as.
<?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="wrap_content">
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow android:id="@+id/TableRow01"
android:layout_width="fill_parent"
android:background="@color/white"
android:layout_height="wrap_content">
<ImageView android:id="@+id/Imagecompany"
android:layout_width="wrap_content"
android:src="@drawable/company"
android:layout_height="wrap_content">
</ImageView>
<TextView android:background="@color/white"
android:textColor="#0000FF"
android:text="Guest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/CompanynameHead">
</TextView>
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:src="@drawable/user"
android:layout_height="wrap_content">
</ImageView>
<TextView android:background="@color/white"
android:textColor="#0000FF"
android:text="Guest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/UsernameHead">
</TextView>
<Button android:text="Log Out"
android:layout_width="60px"
android:layout_height="20px"
android:id="@+id/Logout">
</Button>
</TableRow>
</TableLayout>
</LinearLayout>
try this code …it’s work for ListView Header button click..