我可以个性对我googlemapview的项目和Ontap()对话框? (我想添加按钮就可以了)我想、对我、对话框、就可以

2023-09-05 04:38:30 作者:别人怎么对你,你就怎么对他,生而为人,大家都是第一次,没必要

我有一个图形页面,用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();