点击地图标记后显示自定义对话框

时间:2012-09-17 08:06:07

标签: android google-maps dialog

点击地图标记后,我试图在地图应用程序中显示自定义对话框。这是我的onTap(int index)的代码,根据Android开发人员指南,这是行不通的。这有什么不对?求救!

@Override
    protected boolean onTap(int index) {
        // TODO Auto-generated method stub
          OverlayItem item = mOverlays.get(index);
          Context mContext = getApplicationContext();
          Dialog dialog = new Dialog(mContext);
          dialog.setContentView(R.layout.marker_view);
          dialog.setTitle(item.getTitle());
          TextView textAddress = (TextView) dialog.findViewById(R.id.tv_marker_address);
          TextView textPhone = (TextView)  dialog.findViewById(R.id.tv_marker_phone);
          textAddress.setText(item.getSnippet());
          ImageView image = (ImageView)  dialog.findViewById(R.id.marker_image); 
          dialog.show();
          Button btn = (Button)dialog.findViewById(R.id.btn1);
          btn1.setOnClickListener(this);
          return true;
    }
}

1 个答案:

答案 0 :(得分:0)

也许你需要先扩大布局?