1
package matthew.datacollector;
import android.app.Activity;
import android.view.View;
import android.widget.TextView;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.os.Bundle;
public class DataCollectorActivity extends Activity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
private TextView tv;
private RadioGroup rg;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.tv = (TextView) findViewById(R.id.textView1);
this.rg = (RadioGroup) findViewById(R.id.radioGroup1);
rg.setOnClickListener(this);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
this.tv.setText("lol");
Toast.makeText(this.getApplicationContext(), "hey", Toast.LENGTH_LONG).show();
}
@Override
public void onClick(View v) {
this.tv.setText("lol");
}
}
我不明白为什么这不起作用:/。我希望它设置textview的文本,你甚至可以看到我已经扔在吐司调试。还是什么都没有,我已经试过了没有@Overrides太为什么当我点击收音机组中的另一个单选按钮时,我的onCheckedChanged方法不会被触发?
啊,多么尴尬!谢谢。 – 2012-03-11 19:36:18
虽然,为什么我的onclick事件不能正常工作呢? – 2012-03-11 19:36:54