0

I am using eclipse and brand new to android. I want to know How to print the string entered by the user in EditText column. I am taking the input from the user but i want to use the string entered by the user in my program. How should i do that??

asked Feb 4, 2012 at 4:33

4 Answers 4

1

http://android-er.blogspot.com/2009/07/exercise-hello-world-with-edittext.html

EditText edit_text = (EditText) findViewById(R.id.message_text);
CharSequence edit_text_value = edit_text.getText();
answered Feb 4, 2012 at 4:38
Sign up to request clarification or add additional context in comments.

3 Comments

This is working fine. Thank You. but how should i compare the characters of the string "edit_text_value"?? I was trying "edit_text_value[i]=="edit_text_value"[j]"; like this but its not possible as its a char sequence not an array. please help.
Other people here are right that using toString() will make your lives easier. (Not really mandated) String class also has the method charAt(). But there are also a lot of cool functions on the String class that might help you achieve what you want to do without manipulating chars. docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html
1

It has to have .toString()

String strEditText = editText.getText().toString(); // For getting text from EditText System.out.println ( strEditText ); // For Printing

answered Feb 4, 2012 at 4:50

2 Comments

i tried EditText edit_text = (EditText) findViewById(R.id.message_text); CharSequence edit_text_value = edit_text.getText(); and This is working fine. Thank You. but how should i compare the characters of the string "edit_text_value"?? I was trying "edit_text_value[i]=="edit_text_value"[j]"; like this but its not possible as its a char sequence not an array. please help.
@user1188874 - You can use 'edit_text_value.charAt(i)==edit_text_value.charAt(j)'
0

please try this

String strEditText = editText.getText().toString();
System.out.println ( strEditText );

now use this strEditText for using edittext value

answered Feb 4, 2012 at 4:43

4 Comments

It always gives an error. First line of code gives an error says can't make a reference.
EditText editText =(EditText)findViewById(R.id.youredittext); please add this line before these two lines.
i tried EditText edit_text = (EditText) findViewById(R.id.message_text); CharSequence edit_text_value = edit_text.getText(); and This is working fine. Thank You. but how should i compare the characters of the string "edit_text_value"?? I was trying "edit_text_value[i]=="edit_text_value"[j]"; like this but its not possible as its a char sequence not an array. please help
why you compare charsequnce ? use string to compare the Values . ok
0

Its Very Simple,

String strEditText = editText.getText().toString(); // For getting text from EditText
System.out.println ( strEditText ); // For Printing 

You can also visit here for example of how to retriver EditText's String.

answered Feb 4, 2012 at 4:40

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.