Reputation: 13
what i trying to do is i am adding some text in the edit text and i want that on submit button it get added in text view provided below...therefore,everytime i add d text on submit it should get appended in that text view but the problem is its getting overwritten
here s d code:
// submit button
final Button button = (Button) findViewById(R.id.Submit);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
EditText et = (EditText) findViewById(R.id.EnterText);
TextView history=(TextView) findViewById(R.id.history);
history.setText(et.getText().toString());
}
});
Upvotes: 0
Views: 598
Reputation: 11571
use this to append the text in next line :
history.setText(history.getText() +"\n" +et.getText().toString());
Upvotes: 0
Reputation: 30855
try this
history.setText(history.getText() + "\n" + et.getText().toString());
Upvotes: 1
Reputation: 576
Change
history.setText(et.getText().toString());
To
history.setText(history.getText() + et.getText().toString());
This should append the new Text.
Upvotes: 0