fer*_*tar 26
尝试这样的事情:
private Thread thread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutxml);
final MyActivity myActivity = this;
thread= new Thread(){
@Override
public void run(){
try {
synchronized(this){
wait(3000);
}
}
catch(InterruptedException ex){
}
// TODO
}
};
thread.start();
}
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(thread){
thread.notifyAll();
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
等待3秒钟继续,但如果用户触摸屏幕,则通知线程并停止等待.
| 归档时间: |
|
| 查看次数: |
71701 次 |
| 最近记录: |