如何设置监听器的TextView? [英] How to set Listener for TextView?
本文介绍了如何设置监听器的TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经设置监听器TextView的,但它不是working.I想开始text.I的点击活动已经把我的code任何人都可以建议我的任何变化。
I have set listener for the TextView but it is not working.I want to start activity on click of text.I have placed my code can anyone suggest me any changes.
// This is my code
public void onClick(View v) {
// TODO Auto-generated method stub
int i = v.getId();
//String roomName = textView[i].getText().toString();
//Intent intentDeviceOperation = new Intent(v.getContext),DeviceOperation.class);
//startActivity(intentDeviceOperation);
//Intent i1 = new Intent(v.RoomForSpecificUser.this,DeviceOperation.class);
//RoomForSpecificUser.this.startActivityForResult(i1,7);
Intent ii = new Intent();
ii.setClass(RoomForSpecificUser.this, DeviceOperation.class);
}
这不是开始另一个活动,甚至没有得到任何错误也。
It is not starting another activity and even not getting any error also.
推荐答案
这样来做,事情会工作
TextView tv = (TextView) findViewById(R.id.textView);
tv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent ii = new Intent();
ii.setClass(RoomForSpecificUser.this, DeviceOperation.class);
startActivity(ii);
}
});
这篇关于如何设置监听器的TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文