I have a ListView
in my app's code, which when clicked uses an AdapterView.OnItemClickListener
to detect clicks. The problem is, when I click on an item , that item's background turns to white, instead of the default orange. Like this:
Also, when I dont use AdapterView, the clicked items turn orange without any problem. How do I make the clicked item's background orange again?
EDIT:
layout of list: main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#00000000">
<!-- ListView (grid_items) -->
<ListView android:id="@+id/listview"
android:layout_height="fill_parent"
android:textSize="15px"
android:layout_width="fill_parent"
android:background="#00000000">
</ListView>
</RelativeLayout>
onCreate():
public void onCreate(Bundle savedInstanceState) {try{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv= (ListView)findViewById(R.id.listview);
lv.setBackgroundColor(Color.TRANSPARENT);
lv.setCacheColorHint(Color.TRANSPARENT);
//......calculations
for(int q = 0; q <v; q++){
HashMap<String, String> map = new HashMap<String, String>();
map.put("col_1", array[q]);
fillMaps.add(map);
lv.setOnItemClickListener(onListClick);
}
//......calculations
}
AdapterView:
private AdapterView.OnItemClickListener onListClick=new AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView<?> parent,View view, int position, long id)
{
lv.setBackgroundColor(Color.TRANSPARENT);
lv.setCacheColorHint(Color.TRANSPARENT);
//.....calculations
}
Custom theme being used:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">35dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>