我可以个性对我googlemapview的项目和Ontap()对话框? (我想添加按钮就可以了) [英] Can i personalize the onTap() dialog of the items on my googlemapview?? (i wanna add a button on it)

查看:143
本文介绍了我可以个性对我googlemapview的项目和Ontap()对话框? (我想添加按钮就可以了)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图形页面,用itemizedoverlays,完全像在Android开发者指南的例子:的 http://developer.android.com/resources/tutorials/views/hello-mapview.html

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

在这个例子中,当你$在物品P $ PSS,它表现出了丝毫不差和身体对话:

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

没关系,它工作正常,我仍然需要显示该对话框,但我需要添加一个按钮,当我preSS它加载一个新的活动,也许一些更多的文本行。

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

推荐答案

当然,这是可能的。

这是我要做的事。请注意,还有一个setNeutralButton可能的。照片 这3个按钮可以使用,据我所知。

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.

看这一点。 AlertDialog在Android开发者

      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();

这篇关于我可以个性对我googlemapview的项目和Ontap()对话框? (我想添加按钮就可以了)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆