ProgressBar的简单使用

滚动体在安卓程序中使用也计较多 。
的几个常用属性和方法
:max="200"滚动条最大值
:="0" 滚动条当前值
:="" 滚动条是否可见
(int) 设置当前值


处理动态加载滚动条
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//请求设置窗口标题栏滚动条requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);setContentView(R.layout.activity_main);pb = (ProgressBar)findViewById(R.id.firstBar);value = http://www.kingceram.com/post/(EditText)findViewById(R.id.value);//设置滚动条可见setProgressBarIndeterminateVisibility(true);//创建一个HandlermHandler = new Handler(){@Overridepublic void handleMessage(Message msg) {super.handleMessage(msg);//处理消息switch (msg.what) {case MSG://设置滚动条和text的值pb.setProgress(pro);value.setText(Integer.toString(pro));break;default:break;}}};start();}private void start(){new Thread(new Runnable() {@Overridepublic void run() {int max = pb.getMax();try {//子线程循环间隔消息while (pro < max) {pro += 10;Message msg = new Message();msg.what = MSG;mHandler.sendMessage(msg);Thread.sleep(1000);}} catch (InterruptedException e) {e.printStackTrace();}}}).start();}
效果图:
【ProgressBar的简单使用】

ProgressBar的简单使用

文章插图