我创建了一个类并从视图中扩展它,还实现了Runnable接口。在onTouchEvent中,我调用:new Thread(this).start()
。
这是我的类:
public class test extend View interface Runnable{
----some code------
public void onTouchEvent(MotionEvent event){
----somecode------
new thread(this).start();
----somecode------
}
public void run(){
-----somecode-------
invalidate();
-----somecode-------
}
}
但我收到了这个错误:
只有创建视图层次结构的原始线程才能触摸其视图
我该如何解决这个问题?