Day17-进度条控件
来源:互联网 发布:java jdk 编辑:程序博客网 时间:2024/06/07 01:45
.java代码:
package com.example.day1;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 progress extends Activity implements OnClickListener{private Button one;private Button two;private ProgressBar progress;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.progress);one=(Button) findViewById(R.id.one); two=(Button) findViewById(R.id.two); progress=(ProgressBar) findViewById(R.id.progress); //点击事件 one.setOnClickListener(this); two.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.one:int currentprogress1=progress.getProgress(); // 获取当前进度值int prog1=(int) (currentprogress1*1.2); // 设置增加的进度值progress.setProgress(prog1);break;case R.id.two:int currentprogress2=progress.getProgress();int prog2=(int) (currentprogress2*0.5);progress.setProgress(prog2); // 设置减少的进度值break;}}}
.xml代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleSmall" /> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleLarge"/> <ProgressBar android:id="@+id/progress" android:layout_width="match_parent" android:layout_height="wrap_content" android:progress="30" android:layout_marginTop="50dip" style="?android:attr/progressBarStyleHorizontal"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/one" android:text="增加"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/two" android:text="减少"/> </LinearLayout> </LinearLayout>
0 0
- Day17-进度条控件
- day17
- day17
- day17
- Day17
- Day17
- day17
- DAY17
- Day17
- 进度条控件
- 进度条控件
- 进度条控件
- 控件进度条
- delphi 使用进度条控件
- 高级进度条控件源码
- Symbian 进度条控件
- 进度条控件的绘制
- vc 进度条控件
- [leetcode]Valid Parentheses题解
- 中水处理设备:一体化中水处理设备特点阐述
- NSURLConnection 向服务器发送post请求
- Chapter03-跨进程共享内核对象
- quick cocos2dx 2.2.5Plus中无解的问题
- Day17-进度条控件
- 环境配置
- 【编程之美】1.1让cpu占用率曲线听你指挥
- 16. 3Sum Closest Leetcode Python
- 中水处理设备:城市中水回用设备处理技术解析
- ios:KVC的概述与使用
- IMDG产品功能扩展
- iOS:KVO的概述与使用
- 博客第一篇文章--简单的NTRU 加密算法的编程实现