我有这个 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="20dip"
android:gravity="center_horizontal"
android:text="@string/app_name"
android:textSize="25dip"
android:textStyle="bold"
android:typeface="serif" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="150dip"
android:layout_marginBottom="10dip"
android:contentDescription="@string/iv_restaurantImage"
android:src="@drawable/ic_launcher" />
<ListView
android:id="@+id/lv_restaurant_description_information"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
列表视图是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dip"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:typeface="serif"
android:textSize="15dip" />
<TextView
android:id="@+id/tv_value"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:text="@string/IV_LOGO_DESCRIPTION"
android:textSize="20dip" />
</LinearLayout>
列表视图标题是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rl_simple_list_item_header"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/orderMeal"
android:layout_marginLeft="20dip"
android:id="@+id/tv_restaurant_description_orderMeal"
android:drawableTop="@drawable/order_meal" />
<TextView
android:id="@+id/iv_simple_list_item_header_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/favorite"
android:layout_alignParentRight="true"
android:layout_marginRight="20dip"
android:drawableTop="@drawable/favorite"/>
</RelativeLayout>
在java活动中,我像这样将标题添加到listview
lv_restaurantInformation = (ListView) findViewById(R.id.lv_restaurant_description_information);
View header = LayoutInflater.from(this).inflate(
R.layout.simple_list_item_header, null);
tv_favorite = (TextView) header
.findViewById(R.id.iv_simple_list_item_header_favorite);
lv_restaurantInformation.addHeaderView(header);
一切都很好,应用程序正在运行,现在我想获取列表视图标题上的元素,如何?以及如何为他们设置 onclick 监听器?