I have a listbox where i choose the elements i want to download by a checkbox, and a FloatingActionButton to confirm. The problem is that on my phone(Android 5.0.2) i get a "Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference" On my tablet (Nexus7 Android 6.0) everything work!
FloatingActionButtonDone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int j = 0; j < ListActivityListView.getCount(); j++) {
v = ListActivityListView.getChildAt(j);
//Here im having troubles!
ck = (CheckBox) v.findViewById(R.id.ListActivityCheckBox);
if (ck.isChecked()) {
/*
Stuff to download ++
*/
}
}
/*
Here I have the code to download my stuff
*/
}//End of onClick
});//End of FloatingActionButtonDone.setOnClickListener
Where: - ck is a CheckBox ck, declared in my class variables. - ListActivityListView is the ListView inside my activity.
I repeat same code works on my table, but doesn't on my phone. So i have literally no idea. Since my project is composed by 12 classes, i tried to post here the relevant code i'm having trouble with.
Aucun commentaire:
Enregistrer un commentaire