ImportError: No module named items
2015-04-29 16:07
295 查看
ProgressBar进度条的使用:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <ProgressBar android:id="@+id/ProgressBar01" style="?android:attr/progressBarStyleHorizontal" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content"></ProgressBar> <ProgressBar android:id="@+id/ProgressBar02" android:visibility="gone" android:max="100" android:progress="50" android:secondaryProgress="70" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content"></ProgressBar> <Button android:id="@+id/Button" android:text="start" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> </LinearLayout>
package com.Aina.Android; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ProgressBar; public class Test_ProgressBar extends Activity { /** Called when the activity is first created. */ private ProgressBar pBar1, pBar2; private Button btn; protected static final int STOP = 0x108; protected static final int NEXT = 0x109; private int iCount = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_PROGRESS);// 设置窗口属性 this.setProgressBarVisibility(true);// 显示 setContentView(R.layout.main); pBar1 = (ProgressBar) this.findViewById(R.id.ProgressBar01); pBar2 = (ProgressBar) this.findViewById(R.id.ProgressBar02); btn = (Button) this.findViewById(R.id.Button); pBar1.setIndeterminate(false); pBar2.setIndeterminate(false); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub pBar1.setVisibility(View.VISIBLE); pBar2.setVisibility(View.VISIBLE);// 设置为可见 pBar1.setMax(100);// 设置最大值 pBar1.setProgress(0); pBar2.setProgress(0);// 设置当前值 new Thread(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub for(int i=0;i<10;i++){ try{ iCount = (i+1)*20; Thread.sleep(1000); if(i==4){ Message msg = new Message(); msg.what = STOP; Test_ProgressBar.this.mHandler.sendMessage(msg); break; }else{ Message msg= new Message(); msg.what = NEXT; Test_ProgressBar.this.mHandler.sendMessage(msg); } }catch(Exception ex){ ex.printStackTrace(); } } } }){ }.start(); } }); } private Handler mHandler = new Handler() { public void handleMessage(Message msg) { switch(msg.what){ case STOP://到了最大值 pBar1.setVisibility(View.GONE); pBar2.setVisibility(View.GONE);//设置进度条不可见 Thread.currentThread().interrupt();//中断当前线程. break; case NEXT: if(!Thread.currentThread().isInterrupted()){//当前线程正在运行 pBar1.setProgress(iCount); pBar2.setProgress(iCount);//设置当前值 Test_ProgressBar.this.setProgress(iCount*100); Test_ProgressBar.this.setSecondaryProgress(iCount*100); } break; } super.handleMessage(msg); } }; }
相关文章推荐
- python scrapy 爬虫ImportError: No module named items
- 解决ImportError: No module named items
- ImportError: No module named items
- ImportError: No module named items
- ImportError: No module named 'requests'
- ImportError: No module named setuptools
- 关于Linux下ImportError: No module named msvcrt
- ubuntu16.04 python2.7.12 报“ImportError: No module named site”错
- ImportError: No module named 'tensorflow.tensorboard.tensorboard'
- ImportError: No module named TileCache.Service
- python2.6升2.7后报ImportError: No module named pkg_resources
- 【python+mysql】在python中调用mysql出问题 ImportError: No module named MySQLdb.constants
- django ImportError: No module named (operations)这个是app名字
- centos7升级python,yum出现问题“ImportError: No module named urlgrabber.grabber”
- 安装net-snmp出现ImportError: No module named setuptools
- 报错 ImportError: No module named model_selection 的解决办法
- pybrain 的安装及报错 ImportError:No module named structure的解决方案
- linux环境下cx_Oracle的“ImportError: No module named cx_Oracle”
- ImportError: No module named matplotlib.pyplot
- python错误 ImportError: No module named setuptools 解决方法