我的屏幕上有對話框。當我觸摸屏幕對話框關閉。我想對話框不應該關閉在外面touch.My代碼下面給出: -如何使對話框在外部觸摸時保持打開
public class Dialogue extends Activity{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialogue);
this.setFinishOnTouchOutside(false);
displayDialogue();
}
private void displayDialogue(){
final AlertDialog.Builder myDialogue = new AlertDialog.Builder(this);
myDialogue.setMessage("Please check your voice input output settings.It should be ON");
TextView messageView = new TextView(this);
messageView.setGravity(Gravity.CENTER);
myDialogue.setView(messageView);
myDialogue.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(Dialogue.this, MainActivity.class);
startActivity(i);
finish();
}
});
AlertDialog dialog = myDialogue.create();
dialog.show();
}
集可取消爲虛假 –
@ user2493740有一個upvoting /標記答案的習慣解決了有用的後 – CRUSADER