Android Projects

Android Development Books

Monday

How to create Android Radio Button

In android , how to create Dialog with select option by using UI.

First you must be create new project by using following steps
  1.  Create new project name : SelectOptionItem
  2. Go to Java file then type following Java code.

public class SelectOptionItem  extends Activity{
@Override
protected void onCreate(Bundle icircle) {
super.onCreate(icircle);
setContentView(R.layout.main);


final String items[] = {"item1","item2","item3"};
AlertDialog.Builder builder=new AlertDialog.Builder(SelectOptionItem.this);
builder.setTitle("Title");

builder.setSingleChoiceItems(items, 0,new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int whichButton) {
// You can write here OnClick Action
         }
    })

.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// You can write here OnClick OK Action
             }
     })

.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
             }
     });
builder.show();
           }
    }
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments

Thanks for your comment

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

Related Posts Plugin for WordPress, Blogger...
© Google Android Lovers
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0