I am trying to implement a scenario in which user will selection one option among many in a group. See picture below:
In figure above, under group named Sauce, there are 3 options. User needs to check only 1 option among these. e.g. If user previously selected "Hot". After that he taps on "Mild" then check must disappear from "Hot" and appear on "Mild". I hope you got this point.
To achieve this approach, I need to have reference of either a group's childviews
or individual checks
, so that I can toggle my checkmarks. I really don't know what to do at this point... Please help me. Thanks..
childlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dip" >
<TextView
android:id="@+id/childname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:layout_alignParentLeft="true"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/checkmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/childname"
android:layout_alignParentRight="true"
android:layout_marginRight="22dp"
android:background="@android:color/transparent"
android:src="@drawable/checkmark" />
</RelativeLayout>
Child OnClick Listener
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
//how to get reference to other children here to toggle checkmark of current as well as previously tapped child's checkmark?
return false;
}
});