快速提问,您是否可以从处理程序中访问UI小部件?在下面的示例中,文本通过消息处理程序进行,我更新了TextView小部件,但文本未显示在小部件中。
示例:
public class FooActivity extends Activity {
@InjectView(r.id.show_something) TextView showSomethingText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
someService = new SomeService(this, fooHandler);
}
private final Handler fooHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
showSomethingText.setText((String)msg.obj);
}
}
}