0
我有一些问题OnTouchListener
。我希望每次用户触摸屏幕前往某个活动。问题在于,当我触摸屏幕时,它会为当前活动做一些类似刷新的事情,并且它会启动(当前活动包含ViewFlipper
,当触摸屏幕时,视图快速启动将从开始翻转)。只有第二次触摸应用才能进行下一个活动。任何人都可以帮我解决这个问题吗?OnTouchListener无法正常工作
我现在的活动来延长OnTouchListener
,我设置myviewflipper.setonTouchListener(this)
和我onTouch()
方法是:
@Override
public boolean onTouch(View v, MotionEvent event) {
finish=true;
Intent intent = new Intent(getBaseContext(), FinishApplication.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
return true;
}
后,我触摸屏幕被称为onPause()
和onResume()
。在onResume()
方法中,我启动一些定时器进行一些更新(更新完成后,幻灯片将开始播放),我认为这就是我的活动刷新的原因。我只在屏幕触摸后才设置变量布尔值finish
至true
,并且仅在finish
为false
但未起作用时才开始更新。我的变量未设置为true。任何其他想法如何解决这个问题?
@Override
protected void onResume() {
super.onResume();
System.out.println("OnResume ViewPlaylist!!");
t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
Imalive();
}
});
}
}, 300, 30000);
if (finish != true) {
System.out.println("Start update!");
update = new Timer();
update.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
updateItems();
}
});
}
}, 30000, 20000);
} else {
finish = true;
Intent intent = new Intent(SlideShow.this, FinishApplication.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
}
你用调试器运行你的代码吗? – WarrenFaith 2012-02-20 10:33:38