I have an ExpandableListView with a custom adapter. Each parent (or group) has a TextView and each child (items) has a textview and a switch. My ChildModel has a String name (TextView) and a String[] choices (switch). However, I believe my layouts are not getting inflated properly, because when I expand my ListView, the values on the switch change! Here's my code
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_row_child, parent, false);
}
TextView itemName = (TextView) v.findViewById(R.id.itemName);
Swith itemDescr = (Switch) v.findViewById(R.id.itemDescr);
ChildModel det = catList.get(groupPosition).getItemList().get(childPosition);
itemName.setText(det.getName());
// itemDescr.setText(det.getChoices()[0] + det.getChoices()[1]);
itemDescr.setTextOff(det.getChoices()[0]);
itemDescr.setTextOn(det.getChoices()[1]);
return v;
}
The part that I can't figure out is that if I changed the Switch to a TextView and use the line above that's comented out, it displays properly. Can someone explain to me why? Thanks!
Notice how when I switch to a Switch the Toolbar Orientation now says "Yes/No" instead of "Left/Right" and my Units of Measurement doesn't even show "Meters/Feet" anymore