Changing the background color in a ListView disables the highlight color

I have a list of search results that appear in ListActivity. When I change the background color of the ListActivity elements, changing the background color of the first LinearLayout (parent), the OnClick highlighting stops working. Why is this and how can I make this selection still work when I change the background color of my items? On the side of the note, is it possible to change the color of this highlight? Thank.

My XML is something like this:

<LinearLayout>
<LinearLayout>
 <ImageView>
 <LinearLayout>
  <TextView>
  </TextView>
  <TextView>
  </TextView>
  <TextView>
  </TextView>
 </LinearLayout>
</LinearLayout>

and my activity is this:

public class ResultsPage extends ListActivity {
+3
source share
2 answers

- , Android . ListView , XML, . , ListView , , , .

. " " http://developer.android.com/guide/topics/resources/drawable-resource.html

, , . , , . .

+4

, , ListView , .

, drawSelectorOnTop = "true" ListView.

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="true"
/>
+5

Source: https://habr.com/ru/post/1785750/


All Articles