当我从服务器获取数据作为列表并使用Checkboxes
在Android设备中显示时。
部分Checkboxes
正在运作(可点击),但其中一些有时无法点击。
这是我的复选框代码:
<CheckBox
android:id="@+id/empCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/txtCustNo"
android:layout_alignParentRight="true"
android:button="@drawable/custom_checkbox"
android:focusable="false"
android:focusableInTouchMode="false" />
这是我的getView方法代码:
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final ViewHolder viewHolder;
if (convertView == null) {
convertView = mlayouInflater.inflate(R.layout.nodel_row, null);
viewHolder = new ViewHolder();
viewHolder.imageView = (ImageView) convertView.findViewById(R.id.expandableIcon);
viewHolder.checkPickupSelect = (CheckBox) convertView.findViewById(R.id.checkBox1);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
if (mGroupTaskView != null && !mGroupTaskView.isEmpty()) {
viewHolder.checkPickupSelect.setChecked(mGroupTaskView.get(groupPosition).getRollOut().equalsIgnoreCase("B"));
}
if (mGroupTaskView != null && !mGroupTaskView.isEmpty()) {
viewHolder.checkPickupSelect
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mTaskFragment.empSelected(groupPosition, child, viewHolder.checkPickupSelect.isChecked());
}
});
}
if (mGroupTaskView != null && !mGroupTaskView.isEmpty()) {
if (mGroupTaskView.get(groupPosition).getRollOut().equalsIgnoreCase("A"))
viewHolder.checkPickupSelect.setEnabled(false);
}
if (mGroupTaskView.get(groupPosition).getRollOut().equalsIgnoreCase("C")) {
viewHolder.checkPickupSelect.setChecked(true);
viewHolder.checkPickupSelect.setEnabled(false);
}
return convertView;
}
答案 0 :(得分:1)
只需删除这两行就可以了:
android:focusable="false"
android:focusableInTouchMode="false"