Handler handler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what){
case 250:
showToast(String.valueOf(msg.obj));
break;
}
}
};
private void setMessageToMain(){
new Thread(){
@Override
public void run() {
super.run();
Message message = handler.obtainMessage();
message.what = 250;
message.obj = "你好250";
handler.sendMessage(message);
}
}.start();
}
Handler的使用
最新推荐文章于 2022-02-21 19:58:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)