API-Demos->App->Dialog->Text Entry dialog

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

API-Demos->App->Dialog->Text Entry dialog

Postby kodex83 » Mon Jan 05, 2009 7:23 pm

I´m playing with the Dialogs in API Demos.

How can I get the values of the editText in the dialog?

I have add to lines of code the get the value of editbox. But it doesn´t work :(
Please help me.

http://code.google.com/intl/de-DE/android/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         case DIALOG_TEXT_ENTRY:
  2.             // This example shows how to add a custom layout to an AlertDialog
  3.             LayoutInflater factory = LayoutInflater.from(this);
  4.             final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
  5.             return new AlertDialog.Builder(AlertDialogSamples.this)
  6.                 .setIcon(R.drawable.alert_dialog_icon)
  7.                 .setTitle(R.string.alert_dialog_text_entry)
  8.                 .setView(textEntryView)
  9.                 .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
  10.                     public void onClick(DialogInterface dialog, int whichButton) {
  11.  
  12.                         // !!!!!!!!!!!!!!!!!!!! MY CODE !!!!!!!!!!!!!!!!!!!!!!!
  13.                         EditText etrUserName = (EditText)findViewById(R.id.username_edit);
  14.                         String userName=userNameEt.getText().toString();
  15.  
  16.                     }
  17.                 })
  18.                 .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
  19.                     public void onClick(DialogInterface dialog, int whichButton) {
  20.  
  21.                         /* User clicked cancel so do some stuff */
  22.                     }
  23.                 })
  24.                 .create();
  25.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


regards

Stefan
kodex83
Freshman
Freshman
 
Posts: 9
Joined: Wed Dec 03, 2008 6:00 pm
Location: Germay

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests