코드 통과하는 동안 : getChildAt
가 가시 행을 반환하고 나는 또한 눈에 보이지 않는 행을 확인해야 중 하나가 확인되지 않았거나 같은NullPointerException이 ListView가에게
SimpleCursorAdapter ada = new SimpleCursorAdapter(this,
R.layout.custom_layout, ssCursor, new String[] {
"String" }, new int[] {
R.id.txt2 });
lvSms.setAdapter(ada);
btnDel.setOnClickListener(new View.OnClickListener() {
private ArrayList<String> msgArr;
public void onClick(View v) {
LinearLayout ly = (LinearLayout) findViewById(R.id.lv);
ListView lvMsg = (ListView) ly.getChildAt(3);
int listCount = lvSms.getCount();
for (int a = 0 ; a < listCount ; a++)
{
LinearLayout ll = (LinearLayout) lvMsg.getChildAt(a);
LinearLayout l2 = (LinearLayout) ll.getChildAt(0);
LinearLayout l3 = (LinearLayout) l2.getChildAt(0);
CheckBox chkBox =(CheckBox) l3.getChildAt(0);
boolean valueOfChkBox = chkBox.isChecked();
if (valueOfChkBox) {
LinearLayout l4 = (LinearLayout) l2.getChildAt(1);
TextView txt1 = (TextView) l4.getChildAt(0);
msgArr = new ArrayList<String>();
msgArr.add(txt1.getText().toString());
Log.i("hello", txt1.getText().toString());
}
} });
나는 NullPointerException
을 얻고있다. 어떻게 분리 된 버튼으로 확인할 수 있습니까?
코드를 추가 할 수 있습니까? (또는 사용자 정의 어댑터 인 경우 추가 할 수 있습니까? 그 코드)? – Luksprog
@Luksprog 귀하의 요청에 따라 어댑터 코드를 추가했습니다. 친절하게 도와주세요 ... – kamil
성취하려는 것은 무엇입니까? 일반적으로 코드화되지 않습니다. – Barak