如何以编程方式创建一个进度条? [英] How to create a ProgressBar programmatically?

查看:191
本文介绍了如何以编程方式创建一个进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要以编程方式创建一个小的进度。 进度条没有方法来设置样式(我想一个小 进度条)。构造可以采取的AttributeSet,但它是一个 接口和要求我实现了一组功能。有没有一种方法 设置进度条的小风格? (我不能使用XML创建 进度条)

My application need to create a small progressBar programmatically. ProgressBar doesn't have method to set the style (I want a small progressBar). The constructor can take a AttributeSet, however it is a interface and require me implements a set of functions. Is there a way to set the progressBar small style? ( I can't use xml to create progressBar)

推荐答案

在大多数情况下,如果你提供了一个的AttributeSet 手动你必须使用Android的之一。幸运的是,他们已经暴露,描述了一个小的进度条的属性集。使用此code:

Most of the time if you provide an AttributeSet manually you have to use one of Android's. Luckily, they've exposed the attribute set that describes a small progress bar. Use this code:

progressBar = new ProgressBar(activity, null, android.R.attr.progressBarStyleSmall);

这篇关于如何以编程方式创建一个进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆