У меня есть 2 формы .xml форм.Один - это форма заголовка, а другой - отображение списка.Используя представление заголовка, я могу отобразить заголовок.Когда я попытался нажать кнопку в форме заголовка, я не смог получить ответ.Пожалуйста, помогите мне Вот мой код.
//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 как.
<?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>