Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;

Similar presentations


Presentation on theme: "Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;"— Presentation transcript:

1 Android Alert Dialog

2 Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm; public void onButtonClickListener() { button_sbm = (Button)findViewById(R.id.button); button_sbm.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder a_builder = new AlertDialog.Builder(MainActivity.this); a_builder.setMessage("Do you want to Close this App !!!").setCancelable(false).setPositiveButton("Yes",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } ).setNegativeButton("No",new DialogInterface.OnClickListener() {

3 public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } ) ; AlertDialog alert = a_builder.create(); alert.setTitle("Alert !!!"); alert.show(); } ); }

4 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); onButtonClickListener(); }

5


Download ppt "Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;"

Similar presentations


Ads by Google