• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get values ?

 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


How should i get values of text box after user clicks on Ok button ?
 
Ed Burnette
Author
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String value = textEntryView.getText();

See http://developer.android.com/reference/android/widget/TextView.html#getText()
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Prajkti Khadse
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i've tried tha same thing i.e. textEntryView.getText()
but it asks me to typecast the textEntryView to EditText

when i do so, i get a java.lang.ClassCastException

here's the code m working with




and here's the alert_dialog_text_entry.xml file




please help me out...
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try this code

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The inflate method of the LayoutInflater class returns an object of type View. So, your textEntryView reference contains an View object. You cannot downcast it to EditText; you will get ClassCastException.

This is standard Java behavior and nothing specific to Android.

You will have to get a handle on the EditText widget by using findViewById(..) after you have inflated the view. And then do a getText on it.
 
Prajkti Khadse
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chetan....
Thanks Monu....

it worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic