Sunday, February 23, 2014

Questions about Andrews



My home page in the program defines a button to exit the program, I want to achieve when clicking on this button will pop up a
Box, shown above to determine the eject button and Cancel buttons, when you click OK to exit button completely exit the program, click on the Cancel button
When the box disappears, I ask how this implementation, the code written for me, thank you.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Use Dialog can be achieved, the specific API to see it
Reply:
new AlertDialog.Builder (this) This class is the simplest.
Reply:
Head, with AlertDialog, then setMessage, setButton, processing corresponding onclick event on it.
Reply:
 btn.setOnClickListener (new View.OnClickListener () {

@ Override
public void onClick (View v) {
/ / TODO Auto-generated method stub
new AlertDialog.Builder (this)
. SetTitle ("Tip!!")
. SetMessage ("Are you sure to exit?")
. SetIcon (android.R.drawable.ic_dialog_info)
. SetNeutralButton ("OK",
new DialogInterface.OnClickListener () {

@ Override
public void onClick (DialogInterface dialog,
int which) {
/ / TODO Auto-generated method stub
MainActivity.this.finish ();
}
})
. SetPositiveButton ("Cancel",
new DialogInterface.OnClickListener () {

@ Override
public void onClick (DialogInterface dialog,
int which) {
/ / TODO Auto-generated method stub
return;
}
});
}
});

Reply:
Sorry forgot to add. Show () the still that this activity into your name. This little mistake at the back
Reply:
references, 5th Floor tianwangjay reply:
sorry forgot to add back a bit wrong above show () the activity as well that this change you name this <.. / blockquote>



show () in which Canada?
Reply:
reference to the 6th floor u012733603 reply:
Quote: references, 5th Floor tianwangjay reply:

Sorry forgot to add the above bit error behind. Show () the still that this activity into your name. This



show () in which Canada?


Plus what I know, but there is a problem, you just quit the exit of the page rather than completely exit the program ah Andrews
Reply:
You can look at this http://my.eoe.cn/niunaixiaoshu/archive/1227.html

No comments:

Post a Comment