Android Projects

Android Development Books

Tuesday

Dialog with Select Option in Android

In android, by using dialog we can select a option from multiple option using radio buttons.

Example for Dialog with select option :-

public class ExampleApp extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String items[] = {"item1","item2","item3"};
AlertDialog.Builder ab=new AlertDialog.Builder(ExampleApp.this);
ab.setTitle("Title");
ab.setSingleChoiceItems(items, 0,new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// onClick Action
}
})
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// on Ok button action
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// on cancel button action
}
});
ab.show();
}
}



The output will looks like
dialogwithselectoption
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