安卓第十天——Progress组件的简单实现
2011-12-22 22:48
288 查看
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="100"
android:visibility="invisible"
android:id="@+id/progress1"
/>
<ProgressBar
android:layout_width="200dp"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Horizontal"
android:max="100"
android:id="@+id/progress2"
android:visibility="invisible"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击"
android:id="@+id/button"
/>
</LinearLayout>
ProgressBarActivity.java
package cn.class3g.progressbar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
public class ProgressBarActivity extends Activity {
private ProgressBar progress1 =null;
private ProgressBar progress2=null;
private Button button =null;
private int i=0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
progress1 =(ProgressBar) this.findViewById(R.id.progress1);
progress2 = (ProgressBar) this.findViewById(R.id.progress2);
button= (Button) this.findViewById(R.id.button);
button.setOnClickListener(new progress());
}
class progress implements OnClickListener{
public void onClick(View v) {
if(i==0){
progress1.setVisibility(View.VISIBLE);
progress2.setVisibility(View.VISIBLE);
}else if(i<progress2.getMax()){
progress2.setProgress(i);
progress2.setSecondaryProgress(i+10);
}
i=i+10;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="100"
android:visibility="invisible"
android:id="@+id/progress1"
/>
<ProgressBar
android:layout_width="200dp"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Horizontal"
android:max="100"
android:id="@+id/progress2"
android:visibility="invisible"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击"
android:id="@+id/button"
/>
</LinearLayout>
ProgressBarActivity.java
package cn.class3g.progressbar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
public class ProgressBarActivity extends Activity {
private ProgressBar progress1 =null;
private ProgressBar progress2=null;
private Button button =null;
private int i=0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
progress1 =(ProgressBar) this.findViewById(R.id.progress1);
progress2 = (ProgressBar) this.findViewById(R.id.progress2);
button= (Button) this.findViewById(R.id.button);
button.setOnClickListener(new progress());
}
class progress implements OnClickListener{
public void onClick(View v) {
if(i==0){
progress1.setVisibility(View.VISIBLE);
progress2.setVisibility(View.VISIBLE);
}else if(i<progress2.getMax()){
progress2.setProgress(i);
progress2.setSecondaryProgress(i+10);
}
i=i+10;
}
}
}
相关文章推荐
- 安卓第十天——利用handler实现progress组件
- 安卓开发笔记——关于开源组件PullToRefresh实现下拉刷新和上拉加载(一分钟搞定,超级简单)
- 安卓--第十天--蓝牙app实现与BLE设备简单通信
- 安卓第十天——ListView的简单实现
- 安卓之实现一个简单的短信发送功能
- Ionic1x实现简单的评论星级组件
- 关于安卓开发实现可展开的列表组件
- IDispatch接口组件的简单实现
- android(日历+价格)思路简单,实现方便,一看就懂.我是1年安卓新人.
- 安卓(java)计算器简单实现
- 安卓初学者:framelayout实现简单的tab导航栏
- 安卓开发之使用ViewDragHelper简单实现Activity左滑返回
- 安卓下自定义相机简单实现
- vue实现简单表格组件实例详解
- 安卓设备投影到电脑PC端的简单实现
- 用fileupload组件实现的大文件上传简单实例
- struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Emp实体类和对应的配置信息
- struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Action的实现类
- 简单实现安卓app自动更新功能
- Vue组件BootPage实现简单的分页功能