Thursday, July 19, 2012

Selection list in alert dialog box - Android

- Kalimuthu Rengaswamy
Dialog box is one of the most interesting feature in Android. The style and way making it appear depents upon the type of dialog box used and how well we customize it. This blog explains how to create a list of selectable items in an alert dialog box.

Dialog class in Android
Dialog class has 4 sub classes
1. AlertDialog
2. ProgressDialog : A dialog that displays a progress wheel or progress bar.
3. DatePickerDialog : A dialog that allows the user to select a date.
4. TimePickerDialog : A dialog that allows the user to select a time.

Alert dialog
Alert dialog as the name simplies shows an alert to the user. It can manage at the maximum of 3 buttons, a selectable list of items that can even include multiple choice.

Features of alert dialog
1. A title
2. A text message
3. One, two, or three buttons
4. A list of selectable items (with optional checkboxes or radio buttons)  

Creating alert dialog

Single choice alert:
// this declare in golbal value
public int postion
final AlertDialog.Builder singlechoicedialog = new AlertDialog.Builder(this);
final CharSequence[] Report_items = { "Choice I", "Choice II", "Choice III","Choice IV", "Choice V" };
singlechoicedialog.setTitle("SingleChoice Dialog ");
singlechoicedialog.setSingleChoiceItems(Report_items, -1,
new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int item) {
 postion = item;

 // get selected value
 String value = Report_items[item].toString()
 System.out.println("Selected position::" + value);
AlertDialog alert_dialog = singlechoicedialog.create();;

// set defult select value
alert_dialog.getListView().setItemChecked(postion, true);

Multi choice alert:

final CharSequence[] dilogList = { "Choice One", "Choice Two", "Choice Three" };

AlertDialog.Builder multChoiceDialog = new AlertDialog.Builder(this);

//set title for aleart box

multChoiceDialog.setTitle("MultiChoice Dialog");

boolean[] _selections = new boolean[dilogList.length];

multChoiceDialog.setMultiChoiceItems(dilogList, _selections, new DialogInterface.OnMultiChoiceClickListener() {
 public void onClick(DialogInterface dialog,
 int whichButton, boolean isChecked) {

// add positive button here
multChoiceDialog.setPositiveButton("OK",new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 // getting listview from alert box
 ListView list = ((AlertDialog) dialog).getListView();
 StringBuilder sb = new StringBuilder();
 for (int i = 0; i < list.getCount(); i++) {
  boolean checked = list.isItemChecked(i);
  // get checked list value
  if (checked) {
   if (sb.length() > 0)

 Toast.makeText(getApplicationContext(),"Selected digit:"

// add negative button
new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 // cancel code here
AlertDialog alert1 = multChoiceDialog.create();;

List alert:

final AlertDialog.Builder menuAleart = new        AlertDialog.Builder(FiltterlistActivity.this);
final String[] menuList = { "function1", "function2" };
menuAleart.setTitle("list dialog");
menuAleart.setItems(menuList,new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int item) {
  switch (item) {
  case 0:
  // function 1 code here
  case 1:
  // function 2 code here
AlertDialog menuDrop = menuAleart.create();;

Here, I have picked a single feature of alert dialog and explained. You can just copy, paste and execute the code for the results.  

Tuesday, July 17, 2012

Comparison of cloud services

Yogesh Girikumar
Here is a very simple comparison between some of the services exposed by three popular cloud platforms, Amazon AWSOpenStack, and Rackspace Cloud. 

Please do note that this chart is not an exhaustive list of services offered by any provider. It is for illustrative purposes only. This is just a comparison of  some of the ADVERTISED SERVICE offerings and not of all the features or capabilities. The table illustrates only what are being OFFERED as SERVICES, right now. 

As always, things change with time. OpenStack, the popular open source cloud framework that has recently gained much attention and momentum has been adding a lot of features to its arsenal lately; The network-connectivity-as-a-service (NaaS?) component, Quantum being the latest addition; And the volume service component is being renamed Cinder and a lot of development effort is being dedicated to that as a seperate project.