当触摸屏幕时,我使用 OnTouchListener 来显示 layout1,然后当屏幕不被触摸3秒钟后,然后隐藏 layout1。但是我不知道使用哪个事件监视器?
我使用代码:
class unTouchTask extends TimerTask {
public void run() {
if(untouch == true) {
RelativeLayout rl = (
RelativeLayout)findViewById(R.id.relativeLayout2);
rl.setVisibility(View.INVISIBLE);
timer.cancel();
untouch = false;}
}
}
但是在 rl.setVisibility(View.INVISIBLE);:
行有错误
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.