0
我有一个扩展列表片段的类,出于某种原因,片段没有收到列表项的点击。我已经将问题缩小到了行项目中,但我仍然看不出问题所在。这是我的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="fill_parent"
android:orientation="horizontal"
android:focusable="true">
<ImageButton
android:id="@+id/image_button"
android:layout_width="120px"
android:layout_height="120px"
android:scaleType="fitXY"/>
<TextView
android:id="@+id/text_view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"/>
这里是我在我的自定义适配器夸大这个布局:
public View getView(int position, View convertView, ViewGroup parent){
LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = vi.inflate(R.layout.list_item, parent, false);
T t = list.get(position);
TextView tv1 = (TextView) view.findViewById(R.id.text_view1);
tv1.setText(t.getName());
ImageButton image= (ImageButton) view.findViewById(R.id.image_button);
image.setBackgroundColor(Color.parseColor("blue"));
return view;
}
我觉得这是你排布置,首先尝试注释的图像按钮,然后运行和检查 – viv
它添加到ImageButton的'机器人:可调焦=“假” 机器人: focusableInTouchMode =“false”' – Raghunandan
@viv谢谢。可悲的是,这是不是。刚刚尝试过。 –