我想在按钮按下时用字符填充 TextView 我写了这段代码,但它只写了一个字符?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button b = (Button) findViewById(R.id.btn);
final TextView tv =(TextView) findViewById(R.id.txt1);
b.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
String s = tv.getText().toString();
tv.setText( s + "E");
return false;
}
return false;
}
});
}
如何在按钮状态关闭时用字符填充文本视图?