美文网首页
安卓上下文

安卓上下文

作者: 淡妆浓抹ne | 来源:发表于2017-12-01 14:55 被阅读0次

    在Fragment里面,上下文不能使MainActivity.this  只能是getActivity() ;

    ToastUtils.show(getActivity(),"请求成功");

    Handler机制的简单代码

    private Handler handler = new Handler(){

            @Override

            public void handleMessage(Message msg) {

                    if (msg.what == 1){

                            getWeatherData();

                    }

            }

    };

    调用

    handler.sendEmptyMessageDelayed(1,5000);

    5s执行一次。

    相关文章

      网友评论

          本文标题:安卓上下文

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