How do you append text to the existing content of a TextView?
<p>I am trying to develop a calculator app.</p>

<p>When the <em>1</em> button is pressed, the text view is displaying "1" and when I press <em>2</em>, the text view is displaying "2" by replacing "1". </p>

<p>My question is how to display "12" when pressing 1 and 2 one after the other.</p>

<p>My current code is:</p>

<pre><code>package com.calculator.kartheek;

import android.os.Bundle; 
import android.app.Activity;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final TextView textview=(TextView)findViewById(R.id.editText);

    Button one=(Button)findViewById(R.id.one);
    Button two=(Button)findViewById(R.id.two);
    Button three=(Button)findViewById(R.id.three);
    Button four=(Button)findViewById(R.id.four);
    Button five=(Button)findViewById(R.id.five);
    Button six=(Button)findViewById(R.id.six);
    Button seven=(Button)findViewById(R.id.seven);
    Button eight=(Button)findViewById(R.id.eight);
    Button nine=(Button)findViewById(R.id.nine);
    Button zero=(Button)findViewById(R.id.zero);
    Button equals=(Button)findViewById(R.id.equals);
    Button add=(Button)findViewById(R.id.plus);
    Button sub=(Button)findViewById(R.id.sub);
    Button mul=(Button)findViewById(R.id.mul);
    Button div=(Button)findViewById(R.id.division);
    Button dot=(Button)findViewById(R.id.dot);
    Button clear=(Button)findViewById(R.id.clear);

    one.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("1");
            textview.append(INPUT_SERVICE);
        }
    });

    two.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("2");
        }
    });

    three.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("3");
        }
    });

    four.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("4");
        }
    });

    five.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("5");
        }
    });

    six.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("6");
        }
    });

    seven.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("7");
        }
    });

    eight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("8");
        }
    });

    nine.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("9");
        }
    });

    zero.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText("0");
        }
    });

    dot.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            textview.setText(".");
        }
    });
}

@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub

}



}
</code></pre>
