Append text to a TextView datatype

后端 未结 5 1159
陌清茗
陌清茗 2021-02-05 08:39

I\'m a beginner android/java programmer and my background is primarily in C++ and C#. In C# if I have a string variable called myWord and it has a value of \"Hello\" I can appen

5条回答
  •  爱一瞬间的悲伤
    2021-02-05 09:16

    Why nobody suggested getText() method ?

    TextView displayTextView = null;
    displayTextView.setText("text1");
    displayTextView.setText(displayTextView.getText() + "text2");//poor and weak
    

    or better for longer strings:

    SpannableString ss =new SpannableString();
    ss.append("text1").append("text2");
    displayTextView.setText(ss);
    

提交回复
热议问题