0

I want to get the focus on the marker on map v2.

Because it develops for android TV, I need to use arrow keys to get the focus. (There's no touch screen.) I try to use the arrow keys on simulator to select the marker, but it just can move position of the map.

It extends a second question. I have a view to show the content of the marker. But I need it shows the content when marker is SELECTED, not be clicked. I just find the method: setOnMarkerClickListener. The result is not what I needed.

Is there any suggestion? Thanks a lot. :)

PS. In android map v1, we can setfocus on ItemizedOverlay, but it change a lot in v2...

ginnyhuang
  • 63
  • 6

1 Answers1

1

You can capture keys by overriding this method in your Activity:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.i(TAG, "onKeyDown(" + keyCode + ", " + event +")");
    return super.onKeyDown(keyCode, event);
}

The keyCode values are outlined in this developer doc: http://developer.android.com/reference/android/view/KeyEvent.html

Karl
  • 3,394
  • 2
  • 22
  • 31
  • I know this can control the physical keys, but I need is to get the focus on the markers. Like some items: buttons, listview items, or anything we can set focusable that we don't need to override the method. Or is there nothing but writing a focus function myself to control what I select and next selection? That means, if there's hundred of markers, I need to define the next selection when I click the arrow keys for every markers? That's so horrible. :( If I create a list to control the sequence it might happen something we don't want. The marker user next gets might not the closest. – ginnyhuang Sep 11 '13 at 04:32
  • I think for your situation you might be better suited having a list of the markers in your UI, which when the user selects something in the list, the associated marker is highlighted. The problem you have is that you don't really have any choice but to override the default behaviour considering the default behavior is undesirable for you. So when you add a marker, update a `ListView` object with a new entry which holds a reference to the added marker, then use the ListView's `onItemSelected()` method to force focus onto the marker. – Karl Sep 11 '13 at 20:04
  • Um...maybe that's the last method if I can't find other ways to solve the problem. I really don't want to change the UI to adapt the technique (sign). Anyway, thanks so much for your help. :) – ginnyhuang Sep 12 '13 at 03:42