lundi 1 février 2016

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.CheckBox.isChecked()' on a null object reference [duplicate]

This question already has an answer here:

enter image description here this is my fault:

and this is my code

http://ift.tt/1nHrFGp`

it is a function of baseadapter .And per line of listview just only get a CheckBox .but when I use listview.getChildAt(i), i can not obtain a CheckBox. so ..please help!!

@Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    cursor.moveToPosition(position);
                    CheckBox rb=new CheckBox(MainActivity.this);
                    String number=cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)).replace("-","").replace(" ","");
                    rb.setText(number);
                    if(isChecked(number)){
                        rb.setChecked(true);
                    }
                    return rb;
                }
            };




Aucun commentaire:

Enregistrer un commentaire