Reputation: 107
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?
Upvotes: 0
Views: 629
Reputation: 4567
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");
}
});
Upvotes: 1