here am trying to change the background resource for the image, am success in that, but the problem is, when i clicking on all the items in the gridview every item has changes in the background resource, my question is if i click on item which is 0 position it has to change the background resource image, and again if i click on the item which is in 1 position it has to change the background resource and as well as a image on 0 position has to set normal image like without background resource comes to normal state.
public void onItemClick(AdapterView<?> arg0, View vv, int arg2, long arg3) {
// TODO Auto-generated method stub
vv.setBackgroundResource(android.R.drawable.btn_default);
}
Provide me to set only one selected item has to change the image. Thanks in advance.
You need modify your adapter to set background for checked items. For Example:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// creating view
if(item.isChecked()){
veiw.setBackgroundResource(android.R.drawable.btn_default);
}
return view;
}
You actually need to modify the Adapter and for that i will refer you to this question here How to set an image as background image on a click?
Check the accepted answer and do it as described and you are good to go
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.