我正在使用带有叠加项目的谷歌地图 api,并且希望能够在用户单击这些叠加时获得方向。
我希望它链接到我的对话框的中间按钮:
// Middle button
dialog.setNeutralButton("Directions",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
}
});
我收到以下错误“未定义类型 new DialogInterface.OnClickListener(){} 的方法 startActivity(Intent)”
这里有几个答案,但我无法让它们中的任何一个工作。我已经尝试过创建构造函数和调用 getContext()。
我不确定是不是因为我的课是:
public class ItemizedOverlayLayoutActivity extends ItemizedOverlay {
非常感谢任何帮助。
谢谢