ANDROID_MARS学习笔记_S01_011ProgressBar
2016-02-12 13:03
302 查看
文档是这样来设置样式
1.xml
2.java
<ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="@android:style/Widget.ProgressBar.Small" android:layout_marginRight="5dp" />
1.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <ProgressBar android:id="@+id/firstProgressBar" android:layout_width="match_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" /> <Button android:id="@+id/firstButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/firstProgressBar" android:text="增加第一进度"/> <Button android:id="@+id/secondButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/firstButton" android:text="增加第二进度"/> </RelativeLayout>
2.java
package com.marschen.s01_e17_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 MainActivity extends Activity { private ProgressBar progressBar; private Button firstButton; private Button secondButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressBar = (ProgressBar)findViewById(R.id.firstProgressBar); firstButton = (Button)findViewById(R.id.firstButton); secondButton = (Button)findViewById(R.id.secondButton); progressBar.setMax(100); firstButton.setOnClickListener(new FirstListener()); secondButton.setOnClickListener(new SecondListener()); } class FirstListener implements OnClickListener{ @Override public void onClick(View v) { progressBar.incrementProgressBy(10); } } class SecondListener implements OnClickListener{ @Override public void onClick(View v) { progressBar.incrementSecondaryProgressBy(20); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
相关文章推荐
- 【Android】7.7 以后改为在Win10下开发了
- 多长时间更新一次 Android Studio?
- Android编程滑动效果之倒影效果实现方法(附demo源码下载)
- android:Activity数据传递之静态变量
- Android样式的开发:Layer-list篇
- ANDROID_MARS学习笔记_S01_010日期时间控件
- Android样式的开发:Shape篇
- Android编程滑动效果之Gallery+GridView实现图片预览功能(附demo源码下载)
- android:Activity数据传递之对象(parcelable)
- Android Checkbox详解
- 使用音频信息绘制动态波纹
- Android编程滑动效果之Gallery仿图像集浏览实现方法
- android:Activity数据传递之对象(Serializable)
- Android实现定制返回按钮动画效果的方法
- Android 6.0: 动态权限管理的解决方案
- android:Activity数据传递之基本数据类型
- Android编程之判断SD卡状态的方法
- android 半orm 数据库框架(dileber数据库框架)
- android mvp快速开发框架介绍(dileber的集成)
- Canonical 准备与 Android 厂商合作推出更多 Ubuntu Phone