Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle input from a Dialog ?

 
Alessandro Camel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to save a set of data and, in order to do that, I have to ask the name of the set to the user.
The user click on a button (onClick="insertPreferiti") and the system must asks for a name.
So I was thinking about a Dialog with a EditText:



But I can use the entered value ?

I tried to use setText on a invisible TextView (NomePasto), but when I print his value is null!
I think that the main problem is that the two lines below are executed before the user can enter the text. The Dialog is running in a async task.
Is it right ? How can I handle this?

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not use an AlertDialog for text input, I would use an Activity. Or perhaps modify the existing Activity to include and input text box.
 
Alessandro Camel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:I would not use an AlertDialog for text input, I would use an Activity. Or perhaps modify the existing Activity to include and input text box.


Thanks Peter!
But unfortunately I can't modify the activity to include a EditText and,IMHO, using a new Activity only to have an input, it seems to much!

Right now, (maybe it's a mess) I found this solution:



As you can see I pass the flow to a new function ( ContinuaInserimento() ), so I can use the user input!

I know, you are yelling to me ;) but it's working!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic