0
我正在研究基于地图的应用程序。比方说,我有三个类:MapsActivity,MyItemizedOverlay & GetDirectionActivity。在MyItemizedOverlay中,我想在单击肯定对话框按钮后切换到GetDirectionActivity。 ActiveDialog放在onTap方法下,这样我就可以得到GeoPoint。对于这一点,我做了什么: 在ItemizedOverlay类:从AlertDialog按钮切换活动
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
// TODO Auto-generated method stub
int lat = p.getLatitudeE6();
int lot = p.getLongitudeE6();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle("Confirmation");
dialog.setMessage("Confirm this as end point ?");
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(mContext, GetDestination.class);
startActivity(intent);
}
});
dialog.setNegativeButton("No", null);
dialog.show();
return true ;
}
这里IDE显示,我在startActivity(意向)线错误。 我已经试过了也: 在MyItemizedOverlay类:
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
return super.onTap(p, mapView); }
在MapsActivity类:
GeoPoint point2 = null ;
confirmationOverlay.onTap(point2, mapView) ;
int latt = point.getLatitudeE6() ;
int longt = point.getLongitudeE6();
final int endpointArray [] = {latt , longt};
if(some condition to show the alert dialog after tapping)
{
AlertDialog.Builder dialog = new AlertDialog.Builder(MapsActivity.this);
dialog.setTitle("Confirmation");
dialog.setMessage("Confirm this location as end point ?");
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(MapsActivity.this,GetDestination.class);
intent.putExtra("geopoint" , endpointArray);
startActivity(intent);
}
});
dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
}
});
dialog.show();
}
对于if语句什么样的条件下可以使用吗?如果我将它设置为lat> 0,则alertdialog不会在地图上点击而出现。 我知道这是非常愚蠢的,但因为我是新的都在Android & java,我希望你们会考虑它。请帮忙 !
感谢您的答复。我刚刚查看了您的个人资料,发现您提出或回答的所有问题都与谷歌地图有关。看起来像,你也在研究地图应用程序。 [email protected]是我的邮寄地址。如果你希望你可以和我联系。有一个地图怪胎的联系人将是伟大的我。不管怎么说,还是要谢谢你 。 :-) –
欢迎您!:)当然,为什么不呢。 :)如果您需要Google地图的帮助,可以联系我,否则我会与您联系。 :) – pandabear