我在觸摸屏幕時使用了OnTouchListener來顯示layout1。 現在我想要無形佈局1,而屏幕沒有觸摸三秒鐘。 但我不知道我可以使用哪個事件監聽器?如何在用戶未觸摸屏幕時隱藏佈局?
現在問題已解決。 但另一個出現。 我使用:
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.