我试图从最近几天解决这个问题,但没有成功。我已经完成了许多已经可用的解决方案,但非对我有用。我有客户列表视图和自定义行。我使用简单的游标适配器来填充列表视图。在我的自定义行中,我有三个图像视图和一个文本视图。其中一个视图是单击能够打开弹出窗口并行导航到下一个片段。我的问题是,在我选择整行之前,可点击图像不会响应。当我选择行时,它变得可点击。
行
<ImageView
android:id="@+id/iv_LvRow_speedmap_PIcon"
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_weight="0.20"
android:contentDescription="@string/todo"
android:paddingLeft="10dip"
android:src="@drawable/arrow4" />
<TextView
android:id="@+id/tv_LVRow_SpeedMap_PDesc"
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_weight="0.60"
android:ellipsize="none"
android:gravity="center_vertical|center_horizontal"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="@string/textview"
android:textColor="@color/black"
android:textSize="14sp" />
<ImageView
android:id="@+id/ib_LvRow_SpeedMap_InfoIcon"
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_weight="0.10"
android:clickable="true"
android:contentDescription="@string/todo"
android:duplicateParentState="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:src="@drawable/info_icon" />
<ImageView
android:id="@+id/imgView_ArrowImg_speedMap"
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_weight="0.10"
android:contentDescription="@string/todo"
android:src="@drawable/arrow4" />
</LinearLayout>
ListView lv = getListView();
// lv.setItemsCanFocus(true);
// lv.setClickable(true);
// lv.setFocusable(true);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int arg2,
long arg3) {
final String where = "id = " + Long.toString(arg3);
ImageView iv = (ImageView) v
.findViewById(R.id.ib_LvRow_SpeedMap_InfoIcon);
// iv.setClickable(true);
// iv.setFocusable(true);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("id2");
String[] projection = { "name", "description" };
String selection = where;
Cursor cursor = null;
cursor = getActivity().getContentResolver().query(
DatabaseContentProvider.CONTENT_URI_CONCERNS,
projection, selection, null, null);
cursor.moveToFirst();
if (cursor.getCount() > 0) {
String name = cursor.getString(cursor
.getColumnIndex("name"));
System.out.println("name" + name);
String description = cursor.getString(cursor
.getColumnIndex("description"));
System.out.println("description" + description);
info(name, description, v);
}
}
});
}
});
答案 0 :(得分:1)