Android注释在Ui Thread上运行

And*_*yeu 11 multithreading android

是否可以注释在UiThread中运行代码的方法?

runOnUiThread(new Runnable() {
public void run() {
//my code
}});
Run Code Online (Sandbox Code Playgroud)

看起来太复杂,经常使用它.

lud*_*igm 18

看看AndroidAnnotations项目.他们使用注释.据我所知,这是你想要的.它使用编译时代码生成http://code.google.com/p/androidannotations/


注意:

根据文档,@UiThread注释仅表示给定的类/方法应该在UI线程上运行.它意味着使用该注释会打电话给你的UI线程上的方法.

  • 这正是我想要的!非常感谢你! (2认同)