views:

1479

answers:

3

Hi. I have a FrameLayout view which contains one (MapView-like) control and some additional buttons overlaying it. (the layout xml is below).

I want to allow the user to pan/scroll the main view using not only touch but also the Trackball. The problem is - using the trackball just switches the focus between all the controls on the layout, and I cannot seem to find a way to contain the onTrackballEvent to just the MainView.

Any suggestions are welcome, thanks in advance.

<?xml version="1.0" encoding="utf-8"?>

<merge xmlns:android="http://schemas.android.com/apk/res/android"   
    android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout android:id="@+id/pageView" 
    xmlns:panel="http://schemas.android.com/apk/res/com.yappa"
      xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

    <MainView
     android:id="@+id/mainView" 
     android:layout_width="fill_parent"
     android:layout_height="wrap_content">
    </MainView>


    <ZoomControls android:id="@+id/ZoomControls01"
     android:layout_gravity="bottom|center"
     android:layout_height="wrap_content" android:layout_width="wrap_content">
    </ZoomControls>

    <Panel
          ....
    </Panel>

</FrameLayout>

</merge>
A: 

Have you tried playing with the android:focusable property?

Ari
focusable controls how you go from one control to another. not what i meant in the question
Reflog
+1  A: 

the trick is to override the dispatchTrackball in your custom view, and grab the events.

hope this helps someone

Reflog
A: 

Hello,

Whether you were able to implement panning and scrolling triggered by trackball events?

regards -Nitin

beedroid