我的屏幕上有对话框。当我触摸屏幕对话框关闭。我希望对话框不应该在外部触摸时关闭。我的代码如下:-
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();
}