알림 대화 상자를 만들려고 시도하지만 애플리케이션을 실행할 때 표시되지 않습니다. 여기에 내 코드는 다음과 같습니다Android 앱의 AlertDialog가 표시되지 않습니다.
final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Your GPS seems to be disabled, do you want to enable it?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
dialog.cancel();
buildLocationMessage();
}
});
final AlertDialog alert = builder.create();
alert.show();
아직 아무것도. 또한 setButton 메서드가 더 이상 사용되지 않는다는 경고가 나타납니다. –