AlertDialog, Preferences, Builder, PopUp

Quickly share your Android Code Snippets here...

AlertDialog, Preferences, Builder, PopUp

Postby plusminus » Sun Nov 09, 2008 5:07 pm

Tip: Strongly suggested to make the used Strings constants :!:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. new AlertDialog.Builder(this).setMessage("Save to Pref...")
  2. .setPositiveButton("SAVE", new DialogInterface.OnClickListener(){
  3.         @Override
  4.         public void onClick(DialogInterface dialog, int which) {
  5.                 Editor e = YOUR_SURROUNDING_ACTIVITY.this.getPreferences(Context.MODE_PRIVATE).edit();
  6.                 e.putString("PREFERENCES_ID", "hello world");
  7.                 e.commit();
  8.                 dialog.dismiss();
  9.         }
  10. }).setNegativeButton("CANCEL", new DialogInterface.OnClickListener(){
  11.         @Override
  12.         public void onClick(DialogInterface dialog, int which) {
  13.                 dialog.dismiss();
  14.         }
  15. }).show();
Parsed in 0.033 seconds, using GeSHi 1.0.8.4

SDK Version compatible: 1.0 (maybe prior versions too)
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 5 guests