[Solved] Spinner in a listview in android [closed]


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();
      }

7

solved Spinner in a listview in android [closed]