I am creating an imageButton i'm going to setId to the imageButton. But what I got is nullpointerexception error.. can anybody please tell me what have I done wrong? Thank you so much :) I've declared public int count=0;
public int count=0;
final ImageButton button =(ImageButton)convertView.findViewById(R.id.favoritelist_button);
button.setId(count); //null pointer exception
count++;
button.setImageResource(R.drawable.phone);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do something in response to button click
if(!tFave){
button.setImageResource(R.drawable.phone);
tFave = true;
}
else{
button.setImageResource(R.drawable.gmail);
tFave = false;
}
}
});