0

I have a edit_text field in activity_X.xml. I have a button B in activty_X.xml. On clicking button B i need to assign a value to edit_text field. How to do?

1
  • It is basic in android. Study the basics first and it will answer this question. Commented Mar 5, 2013 at 13:50

1 Answer 1

1

you should try something on your own then post any question if you are getting any problem in that...anyways here's how you can implement this

Button buttonOne = (Button) findViewById(R.id.button1);
buttonOne.setOnClickListener(new Button.OnClickListener() {
    public void onClick(View v) {
           EditText editText1 = (EditText) findViewById(R.id.textidinxml);
         editText1.setText("Some text to show on edittext");                    
    }
});
Sign up to request clarification or add additional context in comments.

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.