1

I am new to android development, I have created a string variable with EditText ,how can i assign that string to another string. thanks in advance.

2 Answers 2

4

have you tried: "="? i.e.:-

String oldString = "odl Text";
String newString = oldString;

Simple steps can be:

  1. get text from EditText as string
  2. assign that to some other string variable.

Provide some more information to get better solutions. What problem are you facing?

Sign up to request clarification or add additional context in comments.

21 Comments

actually i wanted the value of the string to be assigned to another string
@sameer: Whats the problem in that? Use = operator to do this.
here is my code txtpassword=(EditText)findViewById(R.id.Editpassword); String strEditText; strEditText=txtpassword.text; if(txtpassword==AdminPwdHandler.strCurrentPassword). here strCurrentPassword is a string variable from another class
@sameer: do you get any error while running this? see log cat to know if error comes or not.
ya i am getting the following error.. incompatible operands EditText and String
|
2
String s1 = "..";
String s2 = s1;

In regard to EditText - its getText() method returns a CharSequence, that is not necessarily a String. You can use .toString() on it.

Comments

Your Answer

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.