I've got code that looks like this:

    case 2:
            final TextView scoretext = new TextView (this);
            return new AlertDialog.Builder(this)
            .setIcon(R.drawable.ic_launcher)
            .setTitle("How cold or hot do you feel today?")
            .setView(qolscorelayout)
            .setPositiveButton("Confirm",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton)
                    {
                        SeekBar qolDialogSeekbar = (SeekBar)qolscorelayout.findViewById(R.id.qolscore_seekbar);
                        todayScore = qolDialogSeekbar.getProgress();
                        showDialog(3);
                    }
                }
            ).create();

qolscorelayout is defined earlier as:

    qolscorelayout = inflater.inflate(R.layout.qolscore_dialog, (ViewGroup)findViewById(R.id.qolscore_dialog_root_element)); //Layout for getting Seekbar in Dialog

I want a TextView inside the dialogue, though, just above the slider.

I was thinking about doing something like:

    case 2:
            final TextView scoretext = new TextView (this); //NEW
            return new AlertDialog.Builder(this)
            .setIcon(R.drawable.ic_launcher)
            .setTitle("How cold or hot do you feel today?")
            .setView(qolscorelayout)
            .setPositiveButton("Confirm",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton)
                    {
                        SeekBar qolDialogSeekbar = (SeekBar)qolscorelayout.findViewById(R.id.qolscore_seekbar);
                        todayScore = qolDialogSeekbar.getProgress();
                        scoretext.setText("" + todayScore); //NEW
                        showDialog(3);
                    }
                }
            ).create();

But how do I get it to put that TextView inside the dialog?

有帮助吗?

解决方案

Just adding to what was already said.

Put the textview in the qolscore_layout. Then you can modify it's content like this:

qolscorelayout = inflater.inflate(R.layout.qolscore_dialog, (ViewGroup)findViewById(R.id.qolscore_dialog_root_element));
final TextView scoretext = (TextView) qolscorelayout.findViewById(R.id.scoretext);
scoretext.setText("" + todayScore); //NEW
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top