zoukankan      html  css  js  c++  java
  • Android线程

    TextView textView1;
    int iCont=0;

    private Thread mThread;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_function_weather);

    textView1=(TextView)findViewById(R.id.textView_weather);

    if(mThread==null){
    mThread=new Thread(runnable);
    mThread.start();//Ïß³ÌÆô¶¯
    }
    else
    {
    Toast.makeText(FunctionWeatherActivity.this,"Runing",Toast.LENGTH_SHORT);
    }

    }

    Runnable runnable=new Runnable() {
    @Override
    public void run() {//run()ÔÚеÄÏß³ÌÖÐÔËÐÐ
    mHandler.obtainMessage(1).sendToTarget();
    }
    };

    private Handler mHandler=new Handler(){
    public void handleMessage(Message msg){//´Ë·½·¨ÔÚuiÏß³ÌÔËÐÐ
    switch (msg.what){
    case 1:
    textView1.setText("1");
    break;
    case 2:
    textView1.setText("2");
    break;
    default:
    textView1.setText("default");
    break;
    }
    }
    };

  • 相关阅读:
    Visual Studio2019安装步骤
    写在第一页的话
    数状数组
    hdu 3501 数学题
    静态邻接表
    最长子序列
    hdu 1094 所想到的
    bellman_ford
    郁闷的一晚
    SPFA + 静态邻接表 模板
  • 原文地址:https://www.cnblogs.com/xuhaifeng/p/7344177.html
Copyright © 2011-2022 走看看