1

点击地图标记后,我试图在我的地图应用程序中显示自定义对话框。这是我根据 Android 开发人员指南的 onTap(int index) 代码,它不起作用。这里有什么问题?请帮忙 !

@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;
    }
}
4

1 回答 1

0

也许你需要先膨胀布局?

于 2012-09-18T14:23:34.170 回答