Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Items in lists not turning orange when clicked?
    primarykey
    data
    text
    <p>I have a <code>ListView</code> in my app's code, which when clicked uses an <code>AdapterView.OnItemClickListener</code> 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:<img src="https://i.stack.imgur.com/9Gf6U.png" alt="enter image description here"></p> <p>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?</p> <p>EDIT: </p> <p>layout of list: main.xml</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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"&gt; &lt;!-- ListView (grid_items) --&gt; &lt;ListView android:id="@+id/listview" android:layout_height="fill_parent" android:textSize="15px" android:layout_width="fill_parent" android:background="#00000000"&gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>onCreate():</p> <pre><code>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 &lt;v; q++){ HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("col_1", array[q]); fillMaps.add(map); lv.setOnItemClickListener(onListClick); } //......calculations } </code></pre> <p>AdapterView:</p> <pre><code>private AdapterView.OnItemClickListener onListClick=new AdapterView.OnItemClickListener(){ public void onItemClick(AdapterView&lt;?&gt; parent,View view, int position, long id) { lv.setBackgroundColor(Color.TRANSPARENT); lv.setCacheColorHint(Color.TRANSPARENT); //.....calculations } </code></pre> <p>Custom theme being used:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="CustomWindowTitleBackground"&gt; &lt;item name="android:background"&gt;#323331&lt;/item&gt; &lt;/style&gt; &lt;style name="CustomTheme" parent="android:Theme"&gt; &lt;item name="android:windowTitleSize"&gt;35dip&lt;/item&gt; &lt;item name="android:windowTitleBackgroundStyle"&gt;@style/CustomWindowTitleBackground&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload