return 值的单选按钮警报对话框

Radio button alert dialog to return values

在我的 activity 中,我想创建一个带有单选按钮的弹出式警报对话框,选择很少,我希望它们中的每一个在按下 时都 return 一些整数值好的 在警告框上。我如何实现 this.please 帮助。

long a;
    final CharSequence[] items = {" 20min before", " 40min before", " 60min before", " 1hour 30min before"};

    AlertDialog.Builder builder = new AlertDialog.Builder(MovieDetailActivity.this);
    builder.setTitle("Set Reminder For this movie");
    builder.setIcon(R.drawable.ic_action_time);
    builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();


            if (items[item].toString().equals("20min before")) {
                a = 1 * 60 * 1000;
                Toast.makeText(getApplicationContext(), "In 1st", Toast.LENGTH_SHORT).show();

            }
            if (items[item].toString().equals("40min before")) {
                a = 40 * 60 * 1000;
                Toast.makeText(getApplicationContext(), "In 2nd", Toast.LENGTH_SHORT).show();
            }
            if (items[item].toString().equals("60min before")) {
                a = 60 * 60 * 1000;
            }
            if (items[item].toString().equals("90min before")) {
                a = 90 * 60 * 1000;

            }

        }

    });

equalsIgnoreCase用于比较Stringtrim用于删除space.

            if (items[item].toString().trim().equalsIgnoreCase("20min before")) {
                a = 1 * 60 * 1000;
                Toast.makeText(getApplicationContext(), "In 1st", Toast.LENGTH_SHORT).show();

            }else if (items[item].toString().trim().equalsIgnoreCase("40min before")) {
                a = 40 * 60 * 1000;
                Toast.makeText(getApplicationContext(), "In 2nd", Toast.LENGTH_SHORT).show();
            }else if (items[item].toString().trim().equalsIgnoreCase("60min before")) {
                a = 60 * 60 * 1000;
            }else(items[item].toString().trim().equalsIgnoreCase("90min before")) {
                a = 90 * 60 * 1000;

            }