0
자식보기에 대한 확인란과 라디오 버튼을 구현하고 있습니다. 다른 레이아웃도 inflated했습니다. 그러나 문제는 if 및 else 문을 뷰에 사용하고 항상 else 문을없이 실행했습니다. if 진술을 방문해. 아무도 내가 여기서 뭘 잘못했는지 말해 줄 수 없어? 내 아이를위한 chceckbox를 갖고 싶지만 항상 radioButton이 나타납니다. 나는 문이 실행되지 않도록 경우 2를 할당 생각다른 자식이있는 확장 가능한 목록
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;
}
및 이동 :
이 내 빌더 클래스에@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;
}
내부에 생성 :
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;
}}
이
내 어댑터입니다 다른 문장으로. 내가 뭘 할 수있어?
예 2. 반환하지 않습니다. 확인란을 선택하려면 어떻게해야합니까? –
따라서 "2"에 속하는 값을 가져 오는 방법은 –
이 작업을 시도하고 있지만 할 수는 없습니다. 도와 주실 수 있습니까? –