I am setting the background of my ImageButton in getView of adapter the problem I was facing was the background image wasn't properly set, i at first used this.
if(exist) {
bookmark.setBackgroundResource(R.drawable.ic_action_important);
}
but the button background always set the background image to important, then i used this and this solves my problem.
if(exist) {
bookmark.setBackgroundResource(R.drawable.ic_action_important);
} else {
bookmark.setBackgroundResource(R.drawable.ic_action_not_important);
}
I don't know the reason why i have to add the else because in the xml view i set the bookmark default image to ic_action_not_important, i was wondering that why we have to use else when the image ic_action_not_important is already in the adapter view, can anyone please explain. Thanks a lot in advance.