rav
rav

Reputation: 13

adding text in text view on clicking submit button android2.2

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

Answers (4)

Dinesh Sharma
Dinesh Sharma

Reputation: 11571

use this to append the text in next line :

history.setText(history.getText() +"\n" +et.getText().toString());

Upvotes: 0

Pratik
Pratik

Reputation: 30855

try this

history.setText(history.getText() + "\n" + et.getText().toString());

Upvotes: 1

Marc Juschkeit
Marc Juschkeit

Reputation: 576

Change

history.setText(et.getText().toString());

To

history.setText(history.getText() + et.getText().toString());

This should append the new Text.

Upvotes: 0

dira
dira

Reputation: 30594

try..

history.setText(history.getText() + et.getText().toString());

Upvotes: 0

Related Questions