微调在Android的列表视图视图、列表、Android

2023-09-04 07:28:14 作者:该用户未设置昵称

我想创建一个视图完全一样。

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.

推荐答案

如果你想显示一个微调框为每个列表项单击ListView中。它可能与 AlertDialog

If you want to display a spinner for every list item clicked in ListView. Its possible with AlertDialog.

尝试使用的这个

和尝试此块

 list.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0,
        View arg1, int position, long arg3) 
        {
           AlertDialogView();
        }
     }

而$ C $下的 AlertDialogView()会是这样

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