Reputation: 2060
I think I have the opposite problem to a lot of people. I've seen a bunch of people posting that they want items to be highlighted in a listview. I don't want that. I have a simple(ish) app which shows a listview, and it runs immediately when the phone starts (this is according to the client's spec).
The problem is that the first item on the listview is highlighted on start up. As soon as a user touches anywhere on the screen we enter Touch mode and the highlight disappears, but the client is upset with the initial highlight. From what I've read using a keyboard will put you in non-touch mode, and using the touchscreen will put you in touch mode....but the target device I am using (Samsung Galaxy Ace) has no keyboard, yet still somehow comes up in "keyboard mode" (my emulator does too, but at least the emulator has a keyboard so that makes some sort of sense)
Is there anyway to tell a "touchscreen only" device to start up in touch mode? Or, failing that, some simple hack to stop the item being highlighted on my listview?
Thanks
Upvotes: 0
Views: 2796
Reputation: 3401
You could alternatively setFocusableInTouchMode(false) or the equivalent attribute for the things which are being selected.
Upvotes: 0
Reputation: 8072
You could try adding a zero pixel view (that grabs the initial focus) to your layout (above the listview) e.g.
<LinearLayout
android:id="@+id/dummy_focus"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px" />
Upvotes: 2
Reputation: 8072
Can't you just return false for isEnabled in your listview adapter?
boolean enabled = false;
@Override
public boolean isEnabled(int position) {
return enabled;
}
If you need the list items to be selectable you could always runnable & handler to change enabled to true and then do a notifyDatasetChanged
N.B. this is a real hack, none of my listviews have ever started with the first row highlighted. Maybe you have something funky in your layout?
Upvotes: 0