Search code examples
sketchware

setText on textview without replacing sketchware


I need to edit the textview without replacing the all text, for example myText : Hi Like if i click the button it will add "Hello" , so it should be like this "Hi Hello" without replacing the all text.

Sorry for bad English.

I used setText and it replace all text


Solution

  • try this way

    This is your first text view

    textview1.setText("hi");
    
    

    And if your button clicked , add this code for change "hi" to "hi hello"

    button1.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View _view){
            textview1.setText(textview1.getText().toString().concat(" hello"));
        }
    });