Android Studio - startActivity -
getch(); command used in c++ pause program, should use in android studio pause program?
(int = 0; < 2; i++){ if ((b[0].gettext().tostring() == c && b[1].gettext().tostring() == c && b[2].gettext().tostring() == c) || (b[3].gettext().tostring() == c && b[4].gettext().tostring() == c && b[5].gettext().tostring() == c) || (b[6].gettext().tostring() == c && b[7].gettext().tostring() == c && b[8].gettext().tostring() == c) || (b[0].gettext().tostring() == c && b[3].gettext().tostring() == c && b[6].gettext().tostring() == c) || (b[1].gettext().tostring() == c && b[4].gettext().tostring() == c && b[7].gettext().tostring() == c) || (b[2].gettext().tostring() == c && b[5].gettext().tostring() == c && b[8].gettext().tostring() == c) || (b[0].gettext().tostring() == c && b[4].gettext().tostring() == c && b[8].gettext().tostring() == c) || (b[2].gettext().tostring() == c && b[4].gettext().tostring() == c && b[6].gettext().tostring() == c)){ if (c == "x"){ paper.settext("you won game."); } else{ paper.settext("computer won game."); } }
i want pause program displaying result of game using paper.settext(); command.
if inside of activity call this.finish();
edit: i'm not sure you're trying do, it's typically not practice close program without user consenting so. after have shown text may better show dialog such as: "would play again?" [yes] [close game]
you can accomplish following code:
new alertdialog.builder(this) .settitle("play again?") .setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { // start game on } }) .setnegativebutton(android.r.string.no, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { myactivity.this.finish(); //use class name of activity + //to access activity's finish rather try , perform finish on onclick } }) .seticon(android.r.drawable.myicon) .show();
Comments
Post a Comment