雖然在按下中性按鈕時沒有提到關閉或關閉對話框,但我的應用程序仍然覺得按下時需要關閉對話框。AlertDialog中性按鈕消除對話框
任何想法爲什麼?
dialogBox = (AlertDialog) dialogBoxHandler.locationDialog();
dialogBox.setButton(DialogInterface.BUTTON_NEUTRAL, "Use Current Location", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
EditText latitude = (EditText) dialogBox.findViewById(R.id.dl_et_latitude);
EditText longitude = (EditText) dialogBox.findViewById(R.id.dl_et_longitude);
LocationManager lm = (LocationManager) MessageSelection.this.getSystemService(Context.LOCATION_SERVICE);
try {
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double currentLongitude = location.getLongitude();
double currentLatitude = location.getLatitude();
latitude.setText(Double.toString(currentLatitude));
longitude.setText(Double.toString(currentLongitude));
Log.d(TAG, "Latitude " + currentLatitude + " Longitude " + currentLongitude);
} catch (SecurityException e){
Log.d(TAG, e.toString());
}
}
});
dialogBox.show();
問題並不清楚......你是否想在中性按鈕按下時關閉對話框? – rafsanahmad007
@ rafsanahmad007不,我不想關閉 – Sean