I have a CustomAdapter that works fine. The Adapter insert data into my Android GridView. Now i want when an item is checked the BackGround of the Item change to white, and when the other Item is selected, the previous selected Item color chage to GridView background, i mean just with SingleChoiceMode. I have wrote this :
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if(gridView.isItemChecked(position)) { view = gridView.getChildAt(position); view.setBackgroundColor(Color.WHITE); }else { view = gridView.getChildAt(position); view.setBackgroundColor(124333); //the color code is the background color of GridView } } }); But just the first If works, it means when i select a row, the color change to white, but when i select the other row, the previous is still white and the new selected is white too. What should i write in else statement?