美文网首页
2019-04-12 service中修改Fragment的ui

2019-04-12 service中修改Fragment的ui

作者: YuQiao0303 | 来源:发表于2019-04-12 13:22 被阅读0次

service 中:

   //更新ui : handler & messa
        Message msg = new Message();
        msg.what = Constant.UPDATE_TEMPERATURE_HUMIDITY;
        msg.obj = HexUtil.encodeHexStr(data);  //String类型
        HomeFragment.handler.sendMessage(msg);

Fragment 中:

public static Handler handler;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_home, container, false);
        Button rdmindTest = view.findViewById(R.id.send_notice);
        final TextView lastTime = view.findViewById(R.id.last_time);
        //更新ui的handler
        handler = new Handler(){
            @Override
            public void handleMessage(Message msg){
                if(msg.what == Constant.UPDATE_TEMPERATURE_HUMIDITY)
                {
                    lastTime.setText( (String) msg.obj);
                    //lastTime.append("更新ui:"+ i +"\r\n");
                }
            }
        };
...

相关文章

  • 2019-04-12 service中修改Fragment的ui

    service 中: Fragment 中:

  • 2018-07-06

    service和AIDL service执行与UI进程中,所以不要在service中执行耗时操作。 service...

  • Android 生命周期

    Activity Service Fragment

  • Fragment

    一、 Fragment概述 1.Fragment概述 Fragment,也就是碎片,是一种可以嵌入在活动中的UI片...

  • UI Fragment

    1.创建UI Fragment 定义布局 创建UI Fragment的类1.实现Fragment的生命周期方法: ...

  • Activity、Fragment相互调用

    一、Activity控制Fragment或者修改Fragment的控件的值在Fragment中定义一个public...

  • 指南

    Activity Service Broadcast ContentProvider Fragment View ...

  • UI fragment

    1.为托管UI fragment,activity必须做到:在布局中为fragment的视图安排位置;管理frag...

  • Fragment 监听返回按键

    在日常开发中,我们用fragment承担页面UI主要的逻辑,简化activity逻辑。有个场景,fragment需...

  • ProcessLifecycleOwner监听应用生命周期

    前言 在上节中,我们已经讲到了LifeCycle在Activity/Fragment,Service上的使用,大家...

网友评论

      本文标题:2019-04-12 service中修改Fragment的ui

      本文链接:https://www.haomeiwen.com/subject/swlqwqtx.html