英文:
setText on textview without replacing sketchware
问题
我需要在不替换所有文本的情况下编辑文本视图,例如
myText:Hi
如果我点击按钮,它将添加“Hello”,因此它应该是这样的:“Hi Hello”,而不是替换所有文本。
对不起,英语不太好。
我使用了setText,它替换了所有文本。
英文:
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
答案1
得分: 0
尝试这个方法
这是你的第一个文本视图
textview1.setText("你好");
如果你的按钮被点击,添加这段代码将"你好"更改为"你好 你好"
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View _view){
textview1.setText(textview1.getText().toString().concat(" 你好"));
}
});
英文:
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"));
}
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论