我试图在按钮点击时更改TextView的文本。以下是我代码的要点,但似乎没有起作用。我做错了什么吗?谢谢提前。
//xml
<TextView android:id="@+id/textView2" android:text="blah blah blah"></TextView>
<Button android:text="Wrong answer." android:onClick="wrongAns" android:clickable="true"></Button>
//code
TextView theCorrectAnsTextView = (TextView)findViewById(R.id.textView2);
public void wrongAns(View v)
{
theCorrectAnsTextView.setText("TextView text has changed!");
}
wrongAns(View v)
函数从哪里调用?请提供更多详细信息。 - Shafi