activity.oncreate(bundle savedinstancestate)中创建一个handler类的实例, 在这个handler实例的handlemessage回调函数中调用更新界面显示的函数。例如:

Handler errHandler = null; 
public void onCreate(Bundle savedInstanceState) {
       errHandler=new Handler()
        {
            @Override
            public void handleMessage(Message msg){ 
                Bundle b =msg.getData();
                int code=b.getInt("code");
                String reason=b.getString("reason");
                
                openFailPage(code,reason);//在这里面刷新控件
        } 
    
        
}

在其他线程中传值:

  Message obj=new Message();
  Bundle b =new Bundle();
  b.putInt("code", 2061);
  b.putString("reason", "卡操作请求失败");
  obj.setData(b); 
  errHandler.sendMessage(obj);

 

相关文章:

  • 2022-02-02
  • 2022-12-23
  • 2021-11-17
  • 2022-03-03
  • 2021-05-18
猜你喜欢
  • 2021-10-28
  • 2021-08-15
  • 2022-12-23
  • 2021-06-20
  • 2022-02-27
  • 2022-02-24
  • 2021-08-02
相关资源
相似解决方案