I have overridden the dispatchkeyevent in my activity to control some custom UI, but now I want android to handle the key events for my list fragment.
I am able to go through the list with listFragment.getListView().onKeyDown(event.getKeyCode(), event);
with the title in focus,
but how can I click on the up, down, and close imageviews in my row while going through each row?
Heres my list fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background5"
android:orientation="vertical" >
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#25000000"
android:gravity="center"
android:text="Edit your Playlist"
android:textSize="22sp" />
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/header"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false" />
</RelativeLayout>
and my list row
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#50000000" >
<LinearLayout
android:id="@+id/arrows"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/up"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:src="@drawable/arrow_up" />
<ImageView
android:id="@+id/down"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/arrow_down" />
</LinearLayout>
<ImageView
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/arrows" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="25dp"
android:layout_toRightOf="@id/thumbnail"
android:textSize="20sp" />
<ImageView
android:id="@+id/close"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="25dp"
android:src="@drawable/close_button" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#50000000" >
<LinearLayout
android:id="@+id/arrows"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/up"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:src="@drawable/arrow_up" />
<ImageView
android:id="@+id/down"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/arrow_down" />
</LinearLayout>
<ImageView
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/arrows" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="25dp"
android:layout_toRightOf="@id/thumbnail"
android:textSize="20sp" />
<ImageView
android:id="@+id/close"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="25dp"
android:src="@drawable/close_button" />
</RelativeLayout>