[android-developers] EditText (textbox) to String

2009-02-15 Thread Noam

Hello everyone,
I have this piece of code which doesn't seem to work. I can't get the
EditText to a String.

//This is the part before onCreate:

public EditText nametext;
public String name;

//This is after the onCreate (I actually call this method from within
onCreate):

public void dialog() {
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.name);
dialog.setTitle(Name);
Button auto = (Button) dialog.findViewById(R.id.automatic);
auto.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
nametext = (EditText) findViewById(R.id.nametextxml);
name = (String) nametext.getText().toString();
dialog.dismiss();
}
});
dialog.show();
}


Whenever I run this code, it gives me NullPointerException. I know
that this line is the problem:

trackname = (String) tracknametext.getText().toString();

Why is this happening? What's the correct way to convert this to a
String?

Thanks,
Noam.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] EditText (textbox) to String

2009-02-15 Thread Noam

Hello everyone,
I am trying to take an EditText textbox that I set in my XML (named
tracknametext) and turn it into a String.
What is the code to do this?

Thanks,
Noam.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---