모두 안녕하세요, 어댑터에서 동적으로 childview의 라디오 버튼을 생성하는 애플리케이션에서 확장 가능한 목록보기가 있습니다. 확장형 목록보기에서 setOnChildClickListener
에 대한 요구 사항이 있습니다. 하지만 불행히도 라디오 버튼 때문에 해고되지 않습니다. 동적으로 생성 된 라디오 버튼에서 setFocusable/setclickable
을 false로 설정하려고했습니다. 내가 할 때 setOnChildClickListener
가 해고 당한다. 하지만 개별 라디오 버튼을 선택할 수 없습니다. 아무도 도왔습니다. 아무도 이것으로 나를 도울 수 있습니까?setOnChildClickListener가 ExpandableListView에 대해 실행되지 않습니다.
이 내 어댑터 방법
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.expandable_child_radio_layout, null);
RadioGroup radioGroup = (RadioGroup) convertView.findViewById(R.id.radio_group1);
radioGroup.setFocusable(false);
final RadioButton[] rb = new RadioButton[listDataChild.get(this.listOptionsHeader.get(groupPosition)).size()];
radioGroup.setOrientation(RadioGroup.VERTICAL);
for (int i = 0; i < listDataChild.get(this.listOptionsHeader.get(groupPosition)).size(); i++) {
rb[i] = new RadioButton(context);
rb[0].setChecked(true);
final String childText = (String) getChild(groupPosition, i);
rb[i].setText(childText);
rb[i].setId(i + 100);
rb[i].setTag("radio-child " + childText);
fontUtils.changeFontOfRadioButtontoOpenSansRegular(rb[i]);
rb[i].setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.letter_small));
radioGroup.addView(rb[i]);
rb[i].setFocusable(false);
}
return convertView;
}
입니다, 내 어댑터 클래스의 방법이 내 아이의 레이아웃 XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:layoutDirection="ltr"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="20dp">
<RadioGroup
android:id="@+id/radio_group1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RadioGroup>
</LinearLayout>
</LinearLayout>
되는 참조하시기 바랍니다 이것은 내 주요 활동 클래스에서 사용한 온 클릭 방법 .
난 당신이 childview 위해'mExpandableListView.setOnChildClickListener을 리스너를 적용하는 것을 잊었다 생각 클릭 된 버튼에 수동으로 선택을 추가 할 수); ' –
만약 당신이 청취자와 함께 코드를 게시하지 않았다면, 문제는 버튼이 아니며, 또한 문서가 ExListView에 대한 높이 wrap_content를 사용하는 것을 제한하고 동시에 부모 레이아웃을 지정해야합니다. xml 레이아웃의 높이 – Rainmaker
@HarshadPrajapati 내가 hav 사실 내 주요 활동 수업에서 리스너를 사용했습니다. – DRayen