zoukankan      html  css  js  c++  java
  • Handler

    package com.example.administrator.mytestapp.Handler;
    
    import android.os.Handler;
    import android.os.Message;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.widget.ProgressBar;
    
    import com.example.administrator.mytestapp.R;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    public class TextHandler extends AppCompatActivity {
    private static final int MSG_TAG=0x1234;
        private int progress=0;
        private ProgressBar largebar=null;
        private Handler BarHandler=null;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_text_handler);
            largebar= (ProgressBar) findViewById(R.id.largebar);
            BarHandler=new Handler()
            {
                @Override
                public void handleMessage(Message msg) {
                    if (msg.what==MSG_TAG)
                    {
                        if (progress==100)
                        {
                            progress=0;
                        }else
                        {
                           progress+=4;
                        }
                        largebar.setProgress(progress);
                    }
                }
            };
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Message msg=new Message();
                    msg.what=MSG_TAG;
                    BarHandler.sendMessage(msg);
                }
            },0,500);
        }
    }
  • 相关阅读:
    论语言思维的差异
    lua经典问题
    跳槽的故事
    未来一年计划
    腾讯面试题 找重复的数
    nodejs学习
    node记录
    mysql 常用总结
    ubuntu 服务器搭建汇总
    ubuntu下安装golang
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5842562.html
Copyright © 2011-2022 走看看