开发者

Can i personalize the onTap() dialog of the items on my googlemapview?? (i wanna add a button on it)

I have a mapview, with itemizedoverlays, exactly like in the example of android developers guide: http://developer.android.com/resources/tutorials/views/hello-mapview.html

At that example, when you press on a item, it's showed a dialog with a tittle and a body:

protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext)开发者_运维知识库;
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}

ok, it works fine, and i still need to show that dialog, but i need to add A BUTTON, that when i press it it loads a new activity, and maybe some more text lines.

how can i do it? i can't find nothing on google


Sure, that's possible.

This is how I do it. Do note that there's also a setNeutralButton possible.
That's 3 buttons you can use as far as I know.

Look at this as well. AlertDialog on Android Developers

      AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(item.getSnippet())
               .setTitle(item.getTitle())
               .setCancelable(true)
               .setPositiveButton("View Details", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       Intent intent = new Intent(mContext, org.gpsagenda.DetailsContainer.class);
                       intent.putExtra("id", item.ID());
                       intent.putExtra("isConnected", MainMap.getIsConnected());
                       mContext.startActivity(intent);
                   }
               })
               .setNegativeButton("Close window", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       dialog.dismiss();
                   }
               });
        AlertDialog alert = builder.create();
        alert.show();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜