码迷,mamicode.com
首页 > 编程语言 > 详细

新线程 handler

时间:2017-08-23 00:53:26      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:over   put   public   send   发送   xtend   key   ams   end   

class CalculateThread extends Thread {
        private Handler handler;
        @Override
        public void run() {
            super.run();
            Looper.prepare();
            handler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    super.handleMessage(msg);
                    if (msg.what == 0x1233) {
                        int upperNum = msg.getData().getInt("UPPER_NUM");
                        List<Integer> integers = calculateZ(upperNum);
                        Log.e("ouLog" , integers.toString());


                    }
                }
            };
            Looper.loop();
        }
    }
    
    
    //发送到handler
    EditText editText = (EditText)findViewById(R.id.upperNum);
            String upperNum = editText.getText().toString();
            Message msg = new Message();
            msg.what = 0x1233;
            Bundle bundle = new Bundle();
            bundle.putInt("UPPER_NUM", Integer.parseInt(upperNum));
            msg.setData(bundle);
            calculateThread.handler.sendMessage(msg);

新线程 handler

标签:over   put   public   send   发送   xtend   key   ams   end   

原文地址:http://www.cnblogs.com/ouyangping/p/7414130.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!