2013-03-28 47 views
0

我正在開發一個使用google maps api v2的應用程序,並且我有一些標記。使用onInfoWindowClick,我刪除了標記,但我想顯示一個帶有「刪除」和「取消」按鈕的確認彈出窗口,以便用戶可以確認刪除。這可能嗎?這是我的代碼,我的問題是,我無法獲得 「標記」 內部 「的onClick」:Android - 在刪除標記之前顯示確認對話框

public void onInfoWindowClick(Marker marker) { 
LayoutInflater li = LayoutInflater.from(context); 
final View v = li.inflate(R.layout.deletelayout, null); 
AlertDialog.Builder builder = new AlertDialog.Builder(context); 
builder.setView(v); 
builder.setCancelable(true); 
builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which){ 
     //I cannot get access to the marker in here 
    }}); 
builder.setNegativeButton("Cancel", null); 
AlertDialog alert = builder.create(); 
alert.show(); 

//marker.remove(); 

}

回答

4

變化public void onInfoWindowClick(Marker marker) {

public void onInfoWindowClick(final Marker marker) {

你現在應該能夠訪問您的onClick

+0

它的工作原理,非常感謝你! – moyo