我有一个TextView
和一个button
我实现了一个setOnClickListener
方法。我想单击按钮并更新TextView
,不幸的是它只发生在第一次单击中。如您所见,我曾经view.invalidate();
刷新视图,但无法正常工作。这是代码:
public class createtarget extends Activity {
Button mButton;
TextView Board;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createtarget);
mButton = (Button)findViewById(R.id.submit);
Board =(TextView)findViewById(R.id.board);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String s=GiveText(); // Giving a String based on some computations
Board.setText(s);
view.invalidate(); //refreshing View
}
});