주 질문이 여러 번 편집되어 혼동을 야기하므로 다른 스레드가 삭제되도록 플래그를 지정했습니다.setOnCheckedChangeListener (ListView Checkbox가 작동하는 방법)를 얻는 방법
그래서 문제는 다음과 같습니다. ListView에 체크 박스를 채우고 싶은데 listView를 사용자 정의하고 싶습니다. simple_multiple_choice_mode를 사용하지 않고 list_item.xml에 레이아웃을 적용하고 있습니다 (각 행에 대해)
: <CheckBox>
xmlns:android="http://schemas.android.com/apk/res/android" android:paddingLeft="8mm"
android:layout_width="fill_parent"
android:layout_height="wrap_removed" android:id="@+id/nomeAPP" style="?listItem">
</<CheckBox>
내 ListView에는 lista.xml
<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_height="wrap_content"
style="?whiteBackground">
내 어댑터에
list=getListView();
this.setListAdapter(new ArrayAdapter<String>(this,
R.layout.list_item, aux))
그래서 체크 된 항목에 대해 setOnCheckedChangeListener를 만들려고 했으므로 배열 된 항목을 저장할 수 있습니다.
CheckBox cb = (CheckBox) findViewById(R.id.CheckBox01);
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if (buttonView.isChecked()) {
Toast.makeText(getBaseContext(), "Checked",
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getBaseContext(), "UnChecked",
Toast.LENGTH_SHORT).show();
}
}
});
문제는 다음과 같습니다 :
그래서 나는이 청취자를했던 내가 NULL 예외를 얻을. 호기심 것입니다 : 나는 간단한<ScrollView android:id="@+id/widget54" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<CheckBox android:text="Checkbox" android:id="@+id/CheckBox01"
android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox>
</LinearLayout>
</ScrollView>
내 레이아웃을 "전환"그리고 내 ListView에 (내 어댑터)를 잊어 버린 경우, 그것을 작동합니다! 그래서 레이아웃에 어떤 문제가 있습니까?
여러분이 정확히 상황을 볼 수 있도록 새 프로젝트를 만들었습니다. 사용 가능합니다 HERE 지금은 작동하지 않지만 어댑터의 주석을 제거한 경우 ListActivity를 Activity로 변경하고 setContentView를 변경하면 작동합니다 (텍스트의 선택/선택 취소).
내가 찾은 또 다른 흥미로운 점은이 관련이있는 경우 ListActivity와 함께,
이
null 예외 로그를 게시 할 수 있습니까? –