Appending a TextView

I have an app which at current will on the press of a button eg. the number 1 button change a text view to have the number 1 in it. What i need to do is append the view so that say when the number 3 is pressed the text view will say 13 instea of just 3. Here is the switch statement i’m using to handle the button presses.

public void onClick(View c) {

    switch (c.getId()) 
            TextView prs1 = (TextView) findViewById(;



  • Sleep() in java (Android)
  • MediaPlayer: Couldn't open file on client side; Error(-38,0) and more
  • Conflicting content providers facebook SDK
  • 9patch for a lot of resources without losing quality
  • Overlay image to make tutorial in Android app
  • Mockito mocks run actual Android code in Lollipop or greater
  • Related posts:

    View the Task's activity stack
    What is the correct order of calling superclass methods in onPause, onStop and onDestroy methods? an...
    How to lock fragment orientation without locking activity orientation?
    Performance issue on custom font TextView
    Android “Best Practice” use of Intents
    The difference of using MotionEvent.getAction() method
  • Android icon vs logo
  • How to mock a picture in Android Emulator Camera?
  • Android: ListView Selector set to null?
  • Restful API service
  • Positioning an image inside an ImageView with max height and max width set
  • How to exit from the application and show the home screen?
  • 3 Solutions collect form web for “Appending a TextView”

    Use the TextView.append() method.

    Possibly try doing this:

    prs1.setText(prs1.getText() + "1");

    Edit: Sorry I just realized you wanted it to say “13”

    So you would want to do this:

    String text = prs1.getText();
    prs1.setText("1" + text);

    “when the screen first comes up there is a ? in the text view, then when i press the 1 button i want the text view to be 1 then when i press 3 it would need to be 13.”:

    Do this then:

    String text = prs1.getText();
                text = text.replace("?", "");
        prs1.setText("1" + text);

    You can use append() method of textView and the difference between setText and append can be found here. If you make the following changes I think the code would work as expected.

    TextView prs1 = (TextView) findViewById(;
    public void onClick(View c){
        switch (c.getId()) 
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.