Question

I have subclassed BaseExpandableListAdapter in the rows for the BaseExpandableListView I'm having a CheckedTextView. What I want to achieve is that there can only be checked items in one of the groups in the BaseExpandableListView.

So if there is already checked items in group 0 and the user tries to check any items in group 1 then a toast message should display saying something that he has to uncheck the items in group 0 or something like that.

So far my code looks like this:

@Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
            ViewGroup parent) {

        ...

        holder.checkedTextView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                ((CheckedTextView) v).toggle();
            }
        });


        holder.checkedTextView.setText(person.getName());
        holder.checkedTextView.setChecked(person.isTracked());

        return convertView;
    }

I suppose I need to get a reference or something to BaseExpandableListView inside the onClick method to find out which group the currently toggled CheckedTextView is inside?

I'm not sure if my terminology is correct since I just started coding on Android.

No correct solution

OTHER TIPS

I figured out how to do it with the int groupPosition, int childPosition variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top