2010-02-05 56 views
1

我能夠在Googlemap上顯示多個overlayItem,現在我想更改任何特定overlayItem的圖標(以顯示它是當前選定的事件)。我想通過導航按鈕(下一個,上一個)在Google地圖上進行操作。如何更改googlemap上任何overlayItem的狀態?

我正在使用StateListDrawable來顯示OverlayItems的圖標。

圖標文件爲OverlayItem的getMarker方法如下

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:state_selected="true" android:drawable="@drawable/selected_icon"/> 
<item android:drawable="@drawable/unselected_icon"/> 
</selector> 

代碼。

@Override 
public android.graphics.drawable.Drawable getMarker(int stateBitset){ 
    Drawable icon;    
    icon = this.mapActivity.getResources().getDrawable(R.drawable.film_icon); 
    icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); 
    return icon; 
} 

現在的問題是如何更改任何overlayItem /圖標的狀態在地圖上的導航鍵之一,當用戶點擊?

任何幫助,非常感謝。

回答

0

您是否嘗試使用方法setState(int id)?

基本上,您可以使用爲StateListDrawable定義的XML屬性的預定義狀態,並根據它們的ID設置狀態(即android.R.attr.state_active),或者您可以使用addState(int [])添加自己的狀態stateSet,Drawable drawable)。

我沒有自己嘗試,所以不能斷定它正在工作。

+0

是的,這就是我正在做的onclick導航鍵。我已經嘗試setFocus(overlayItem),並嘗試setMarker(Drawable),但沒有運氣:( – 2010-02-10 12:28:45

相關問題