私は地図ベースのアプリケーションに取り組んでいます。たとえば、MapsActivity、MyItemizedOverlay、GetDirectionActivity の 3 つのクラスがあるとします。MyItemizedOverlay では、ポジティブ ダイアログ ボタンがクリックされた後に GetDirectionActivity に切り替えたいと考えています。ActiveDialog を onTap メソッドの下に配置して、GeoPoint を取得できるようにします。このために、私がやったこと: ItemizedOverlay クラス:
@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(intent) 行にエラーがあることを示しています。私もそれを試しました: 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 ステートメントには、どのような条件を使用できますか? 緯度> 0のように設定すると、マップをタップしなくてもアラートダイアログが表示されます。私はこれが非常にばかげていることを知っていますが、私は Android と Java の両方が初めてなので、皆さんがそれを検討してくれることを願っています. 助けてください !