Android 获取ListView项目内的选定视图
我的Android 获取ListView项目内的选定视图,android,android-listview,Android,Android Listview,我的列表视图项包含许多视图 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="1" android:or
列表视图
项包含许多视图
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/messages_listview_item_user_nick"
<!-- other attributes --> />
<TextView
android:id="@+id/messages_listview_item_message_title"
<!-- other attributes --> />
<TextView
android:id="@+id/messages_listview_item_date"
<!-- other attributes --> />
<ImageView
android:id="@+id/messages_listview_item_user_icon"
<!-- other attributes --> />
</RelativeLayout>
<TextView
android:id="@+id/messages_listview_item_message_body"
<!-- other attributes --> />
<TextView
<!-- attributes, no id needed --> />
</LinearLayout>
/
/
/
/
/
/
当用户从列表中选择一个项目时,我希望选择特定的视图
,即所选项目的特定部分。例如,如果用户在项目中选择了ImageView
,我希望获得这个特定的视图。有没有办法做到这一点
目标是根据选定的右侧视图
使AdapterView.OnItemClickListener
具有不同的行为。您可以创建自定义视图或作为行的片段。然后,您可以在自定义视图或片段类中处理每行的每个视图
第二个选项,在自定义适配器集中,分别单击每个视图的侦听器。能否提供第一个示例?第二个是最简单的,但我不知道是否有可能为多个视图使用相同的适配器。似乎我可以分别为每个视图添加一个侦听器,然后为该项添加一个侦听器。这样也有一种“默认”行为。看起来很棒!