-3

I am trying to make a Dialog that has an EditText on it where the user will type and then click OK.

I have not been able to find any examples of this type of Dialog (text to speech translation)

Can you please point me towards a reference or provide an example?

Sam
  • 86,580
  • 20
  • 181
  • 179
Guy Cothal
  • 1,268
  • 1
  • 10
  • 20
  • You should really read the android fundamental documentation to learn.. instead of just always copying from examples. This is far more effective to the process of learning. – JoxTraex Jul 19 '12 at 02:52
  • 1
    You have "(text to speech translation)" in your question. What exactly do you mean by that? – prolink007 Jul 19 '12 at 02:53
  • it means the typos r because it doesn't know the difference between dialog and dialogue...but it looks like stackoverflow corrected it...and @joxtraex i ONLY ask here if for some reason i cant figured it out myself – Guy Cothal Jul 19 '12 at 03:32
  • you can refer to [this link](http://www.androidsnippets.com/prompt-user-input-with-an-alertdialog) for details. – Guanlun Jul 19 '12 at 02:51
  • Edit your question in the perspective of the people who answer this question. If you want us to study for you, we can't. Googling is a type of research. – Tae-Sung Shin Oct 25 '12 at 23:23

1 Answers1

3

You can use the AlertDialog.Builder to customize an alert dialog. In particular the setView() method will allow you to add Views to the dialog, in this case an EditText.

EditText et = new EditText(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(et)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog,int id) {
        String input = et.getText().toString();
                //do something with input
        }
});
AlertDialog ad = builder.create();
ad.show();
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156