GridView单击在android中不工作
您好,我在gridview单击时遇到问题 这是我的xml行代码,我将所有textview、imageview和chexbox设置为android:clickable=“false”,但当我单击项目时,操作无效GridView单击在android中不工作,android,gridview,click,Android,Gridview,Click,您好,我在gridview单击时遇到问题 这是我的xml行代码,我将所有textview、imageview和chexbox设置为android:clickable=“false”,但当我单击项目时,操作无效 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layba
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/laybackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/cadreaccesshadow"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:clickable="false"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageuser"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:clickable="false"
android:layout_marginTop="10dp"
android:src="@drawable/cadretransp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="3dp"
android:layout_marginTop="3dp"
android:clickable="false"
android:orientation="vertical" >
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="13dp"
android:textSize="12sp"
android:clickable="false"
android:textStyle="bold" />
<TextView
android:id="@+id/userjob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="13dp"
android:clickable="false"
android:textSize="12sp" />
<TextView
android:id="@+id/usercompany"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="13dp"
android:clickable="false"
android:textSize="12sp" />
<CheckBox
android:id="@+id/usermail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#cfcfcf"
android:gravity="right|center_vertical"
android:paddingRight="4dp"
android:clickable="false"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
这是我的密码
gridView = (GridView) alertDialogView.findViewById(R.id.gridView1);
gridView.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0,
View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
System.out.println("kkkkkkkkk");
CheckBox checkBox = (CheckBox)arg1.findViewById(R.id.usermail);
checkBox.setChecked(!checkBox.isChecked());
gridArray.get(arg2).setetat(checkBox.isChecked());
customGridAdapter.notifyDataSetChanged();
}
});
gridView=(gridView)alertDialogView.findViewById(R.id.gridView1);
setOnItemClickListener(新的OnItemClickListener()
{
@凌驾
公共链接(AdapterView arg0,
视图arg1、整数arg2、长arg3){
//TODO自动生成的方法存根
System.out.println(“kkkkk”);
复选框=(复选框)arg1.findviewbyd(R.id.usermail);
checkBox.setChecked(!checkBox.isChecked());
get(arg2).setat(checkBox.isChecked());
customGridAdapter.notifyDataSetChanged();
}
});
我的问题是,当我单击“hi Not working”项目时
有人可以帮我试试这个
将android:genderantfocusability=“blocksDescendants”放到您的线性布局中
例如
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/laybackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/cadreaccesshadow"
android:orientation="vertical"
android:padding="5dp"
android:descendantFocusability="blocksDescendants" >
你能发布你的customadapter类…,并尝试在你的应用程序中使用log…。然后看看,它的单击或不尝试我的答案会起作用吗。。。。