我一直在尝试Runnable
在我的应用程序中实现 a,所以我从一些简单的过程开始,但即使这样也不会在TextView
. 令人惊讶的是,我已经覆盖了对象的run()
,但它仍然没有显示。
package com.example.filer;
public class Filesearcher extends Activity implements Runnable {
TextView tvtis;
Thread tr;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_filesearcher);
tvtis = (TextView) findViewById(R.id.tvfirst);
tr = new Thread();
tr.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(5000);
tvtis.setText("Started");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}