Different operations can be performed on the items present in the list by implementing the onClick section.
private void showListDialog(ArrayList<String> list)
{
int l = list.size();
final CharSequence[] items = new String[l]; // not a good way
for (int i = 0; i < l; i++)
items[i] = list.get(i);
final AlertDialog.Builder builder = new AlertDialog.Builder(ActivityName.this);
builder.setTitle("List Dialog");
builder.setItems(items, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
// perform some function on item being clicked
}
});
AlertDialog alert = builder.create();
alert.show();
}
No comments:
Post a Comment