AndreiBogdan
AndreiBogdan

Reputation: 11164

Android. ListView row gets focus

Whenever I wipe the data on the emulator and then run my app on it, the first row in the ListView always gets focus. By this i mean, it has the orange selection on it. Anyone have any idea on how I can get rid of it? I don't have any EditTexts or other Views in the Activity on which I can request focus instead. I'm sure it's something trivial, but I can't seem to find the solution.

Upvotes: 0

Views: 247

Answers (2)

Renjith
Renjith

Reputation: 5803

Add this to your listview xml

<ListView
.................

android:cacheColorHint="@android:color/transparent" 
android:listSelector="@android:color/transparent"
/>

This will make the listview divider color to transparent. So it will not be seen as selected.

Upvotes: 0

faradaj
faradaj

Reputation: 3689

You can do it like that:

ListView listView = (ListView)....;
listView.clearFocus();

Upvotes: 2

Related Questions