0
私は子ビューのチェックボックスとラジオボタンを実装しています。私は別のレイアウトも膨らませています。しかし、問題は私が使用したifとelseステートメントはビューと常にelseステートメントは誰かが私がここで何をしていないのか教えてもらえますか?私は子供のためのchceckboxを持っているが、常にradioButtonが表示されます。異なる子を持つ拡張可能なリスト
public class ExpandableListItem {
public static final int CHILD_TYPE_EDITTEXT = 0;
public static final int CHILD_TYPE_TEXT_FIELD = 1;
public static final int CHILD_TYPE_RADIO_BUTTON = 2;
public static final int CHILD_TYPE_CHECKBOX = 3;
private List<String> childLabels;
private String title;
private int selectionType;
public List<String> getChildLabels() {
return childLabels;
}
public void setChildLabels(List<String> childLabels) {
this.childLabels = childLabels;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getSelectionType() {
return selectionType;
}
public void setSelectionType(int selectionType) {
this.selectionType = selectionType;
}}
これは私のアダプタです:
@Override
public View getChildView(int listPosition, final int expandedListPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
String childLabel = expandableListItemList.get(listPosition).getChildLabels().get(expandedListPosition);
switch (expandableListItemList.get(listPosition).getSelectionType()) {
case ExpandableListItem.CHILD_TYPE_CHECKBOX:
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.checkbox, null);
((CheckBox)convertView.findViewById(R.id.checkfor_Child)).setText(childLabel);
break;
case ExpandableListItem.CHILD_TYPE_EDITTEXT:
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.plaintext, null);
break;
case ExpandableListItem.CHILD_TYPE_RADIO_BUTTON:
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.radiobutton, null);
((RadioButton)convertView.findViewById(R.id.radiofor_child)).setText(childLabel);
break;
default:
case ExpandableListItem.CHILD_TYPE_TEXT_FIELD:
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.textbox, null);
break;
}
return convertView;
}
これが内側に私のビルダークラスである作成:
private ArrayList<ExpandableListItem> getchildExpandableListItem() {
final ArrayList<ExpandableListItem> expandableListItemList = new ArrayList<>();
ExpandableListItem expandableListItem = new ExpandableListItem();
expandableListItem.setTitle(getIntent().getStringExtra("Heading"));
List<String> childLabels = new ArrayList<>();
childLabels = getIntent().getStringArrayListExtra("options");
expandableListItem.setChildLabels(childLabels);
if (expandableListItem.getSelectionType()== 2) {
expandableListItem.setSelectionType(ExpandableListItem.CHILD_TYPE_CHECKBOX);
} else {
expandableListItem.setSelectionType(ExpandableListItem.CCHILD_TYPE_RADIO_BUTTON);
}
expandableListItemList.add(expandableListItem);
return expandableListItemList;
}
私はそれを実行して行かないようにif文で2を割り当てることだと思います他の声明に。私はここで何ができますか?
はいそれは返されません2.チェックボックスを得るために何ができますか? –
どのようにあなたは "2"に属している値を持って来るでしょう –
私はこれを行うtryiingですが、できません、あなたはそれを助けてくださいできますか? –