tags:

views:

79

answers:

1

I have the following XML layout for a ListActivity.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">


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

 <TextView android:id="@+id/android:empty"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:text="No Contacts" />

</LinearLayout>

My problem is that if I have focus on any of the header ImageButtons then when pressing down with the dpad the list get focus on its 7th row (depending on row height), and not on the first row. I've seen the same behavior on Fring application, under Contacts.

I tried by listening for the OnKey event for the KeyEvent.KEYCODE_DPAD_DOWN and triggering a implicit focus on the first item of the list, but I don't know how to do it either.

Do you have any idea on how to focus the first row of the List when getting the focus with a KeyEvent?

A: 

Found it, when using minSdkVersion=3 the behavior is as described in this question. When using minSdkVersion=4 or higher it will work as expected. Don't know why though.

licorna