package com.example.alertdialogsetsinglechoice;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends Activity
{
String[] str={"mp3","Mpeg","wmv","3gp"};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ffff();
}
//setsinglechoice
public void ffff()
{
AlertDialog.Builder aa=new AlertDialog.Builder(this);
aa.setTitle("Choose any one extension type");
aa.setSingleChoiceItems(str, 2, new OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
switch (which)
{
case 1:
Toast.makeText(getApplicationContext(), "Hello Abhi, Its mpeg", 100).show();
break;
case 2:
Toast.makeText(getApplicationContext(), "Hello Guyzz ", 100).show();
break;
case 3:
Toast.makeText(getApplicationContext(), "Hello Guyzz ", 100).show();
break;
case 4:
Toast.makeText(getApplicationContext(), "Hello Guyzz ", 100).show();
break;
default:
break;
}
}
});
aa.show();
}
}