Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I also have this problem. Finally I found the root cause and the solution. To fix this, instead of setting the checkState for the checkBox, you should set its containing listView's checkState.</p> <pre><code> public class MyExpandableListViewAdapter extends BaseExpandableListAdapter { .... private boolean[][] checkedState; private void prepareData() { checkedState =new boolean[itemData.length][]; for (int i=0; i&lt;itemData.length; i++) { groupData.append(i, String.format("Group %d", i)); checkedState[i] = new boolean[itemData[i].length]; Arrays.fill(checkedState[i],false); } } @Override public View getChildView(final int groupPosition, final int childPosition,boolean isLastChild, View convertView, ViewGroup parent) { View itemView = convertView; final ViewHolder vh; if (itemView == null) { LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); itemView = inflater.inflate(R.layout.item_view, null); vh = new ViewHolder(); vh.layout = (CheckableLinearLayout)itemView.findViewById(R.id.layout); itemView.setTag(vh); } else { vh = (ViewHolder)itemView.getTag(); } final ExpandableListView listView = ((ExpandableListView)((MainActivity)context).findViewById(R.id.list)); final int position = listView.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition)); listView.setItemChecked(position, checkedState[groupPosition][childPosition]); vh.layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckableLinearLayout)v).toggle(); checkedState[groupPosition][childPosition] = !checkedState[groupPosition][childPosition]; listView.setItemChecked(position, ((CheckableLinearLayout)v).isChecked()); } }); return itemView; } ... } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload