Hi i wanted to create a view exactly like this.
Once the item in a list view is clicked, a spinner with radio buttons should open.
Hi i wanted to create a view exactly like this.
Once the item in a list view is clicked, a spinner with radio buttons should open.
If you want to display a spinner for every list item clicked in ListView. Its possible with AlertDialog
.
Try to create the alert dialog with radio buttons by using this
and try this block
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0,
View arg1, int position, long arg3)
{
AlertDialogView();
}
}
And the code for AlertDialogView() will be like this
private void AlertDialogView()
{
final CharSequence[] items = {"15 secs", "30 secs", "1 min", "2 mins"};
AlertDialog.Builder builder = new AlertDialog.Builder(ShowDialog.this);
builder.setTitle("Alert Dialog with ListView and Radio button");
builder.setIcon(R.drawable.icon);
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(ShowDialog.this, "Success", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(ShowDialog.this, "Fail", Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
alert.show();
}
in list view whenever you call any item just get the position of clicked item,say 9th element of list view is click on that time call some method,after calling method if your spinner adapter is depends on list of clicked item than first as per the list view's clicked item position fill the spinner adapter than simply open spinner and after you close your spinner and again open with different item of list view than change the spinner adapter.this simple logic should solve your issue i guess thanks Aamirkhan i,