Tuesday, June 4, 2013

[android help] Android: Items in lists not turning orange when clicked?


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:enter image description here


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




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">




android:layout_height="fill_parent"
android:textSize="15px"
android:layout_width="fill_parent"
android:background="#00000000">





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 HashMap map = new HashMap();
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:











.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...