android学习笔记12(ProgressBar--进度条--初级学习)
2012-07-26 22:19
417 查看
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学习笔记(24):进度条组件ProgressBar及其子类
- 学习进度12
- 日语学习之新版初级标准日本语-12 李さんは 森さんより 若いです
- tensorflow学习——ProgressBar输出进度条
- 学习进度12
- 学习进度12
- 【Android学习】进度条ProgressBar
- 学习进度12
- 【android控件学习笔记】ProgressBar进度条
- Android学习篇章5-ProgressBar进度条
- Android学习总结(三)---进度条(ProgressBar)
- JAVA GUI学习 - JProgressBar进度条组件摘录
- 学习进度12
- android学习笔记(4)Intent初级学习
- Android的ProgressBar进度条-android学习之旅(三十一)
- Android学习笔记12——TXT阅读器实例学习
- Android的ProgressBar进度条-android学习之旅(三十一)
- Android学习笔记_76_Android ProgressBar 进度条
- Android学习—超简单实现带进度ProgressBar滚动条