android学习笔记12(ProgressBar--进度条--初级学习)
2014-02-20 14:46
387 查看
MyProgressBar.java
progress_bar.xml
package tk.progressbar; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ProgressBar; public class MyProgressBar extends Activity { private ProgressBar firstBar=null; private ProgressBar secondbBar=null; private Button myButton=null; private int i=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.progress_bar); firstBar = (ProgressBar)findViewById(R.id.firstBar); secondbBar = (ProgressBar)findViewById(R.id.secondBar); myButton=(Button)findViewById(R.id.myButton); myButton.setOnClickListener(new ButtonListener()); } class ButtonListener implements OnClickListener{ @Override public void onClick(View v) { if(i==0){ firstBar.setVisibility(View.VISIBLE); secondbBar.setVisibility(View.VISIBLE); firstBar.setProgress(i); firstBar.setSecondaryProgress(i); }else if(i<firstBar.getMax()){ firstBar.setProgress(i); firstBar.setSecondaryProgress(i 10); secondbBar.setProgress(i); }else{ firstBar.setVisibility(View.GONE); secondbBar.setVisibility(View.GONE); i=-10; } i =10; } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.progress_bar, menu); return true; } }
progress_bar.xml
<?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:id="@ id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <ProgressBar android:id="@ id/firstBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="200dp" android:layout_height="wrap_content" android:visibility="gone" android:max="200" /> <ProgressBar android:id="@ id/secondBar" style="?android:attr/progressBarStyle" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="gone" /> <Button android:id="@ id/myButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="begin" /> </LinearLayout>
相关文章推荐
- android学习笔记12(ProgressBar--进度条--初级学习)
- Android的ProgressBar进度条-android学习之旅(三十一)
- Android的ProgressBar进度条-android学习之旅(三十一)
- Android学习笔记_76_Android ProgressBar 进度条
- Android学习—超简单实现带进度ProgressBar滚动条
- Android的ProgressBar进度条-android学习之旅(三十一)
- 12-13周学习进度
- Android学习笔记(24):进度条组件ProgressBar及其子类
- Android的ProgressBar进度条-android学习之旅(三十一)
- AsyncTask异步任务学习笔记(二、ProgressBar返回加载进度)
- 学习进度安排表(13/12/2——13/12/8)
- ProgressBar 进度条 -- Android学习之路
- Cocos2dx学习笔记12:cocos2dx进度条(ProgressTimer)
- 【Android开发学习27】界面控件之进度条(ProgressBar)
- 学习进度12
- 学习进度 12
- 学习进度安排表(13/12/9——13/12/15)
- Android学习笔记(24):进度条组件ProgressBar及其子类
- 学习进度12
- 日语学习之新版初级标准日本语-12 李さんは 森さんより 若いです