Android控件TextProgressBar进度条上显文字
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 05:19 点击:次
01.public class TextProgressBar extends RelativeLayout implements OnChronometerTickListener {
02. public static final String TAG = \"TextProgressBar\";
03.
04. static final int CHRONOMETER_ID = android.R.id.text1;
05. static final int PROGRESSBAR_ID = android.R.id.progress;
06.
07. Chronometer mChronometer = null;
08. ProgressBar mProgressBar = null;
09.
10. long mDurationBase = -1;
11. int mDuration = -1;
12. boolean mChronometerFollow = false;
13. int mChronometerGravity = Gravity.NO_GRAVITY;
14.
15. public TextProgressBar(Context context, AttributeSet attrs, int defStyle) {
16. super(context, attrs, defStyle);
17. }
18. public TextProgressBar(Context context, AttributeSet attrs) {
19. super(context, attrs);
20. }
21. public TextProgressBar(Context context) {
22. super(context);
23. }
24. //Android开发网提示关键部分在这里
25.
26. @Override
27. public void addView(View child, int index, ViewGroup.LayoutParams params) {
28. super.addView(child, index, params);
29.
30. int childId = child.getId();
31. if (childId == CHRONOMETER_ID && child instanceof Chronometer) {
32. mChronometer = (Chronometer) child;
33. mChronometer.setOnChronometerTickListener(this);
34.
35. // Check if Chronometer should move with with ProgressBar
36. mChronometerFollow = (params.width == ViewGroup.LayoutParams.WRAP_CONTENT);
37. mChronometerGravity = (mChronometer.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK);
38.
39. } else if (childId == PROGRESSBAR_ID && child instanceof ProgressBar) {
40. mProgressBar = (ProgressBar) child;
41. }
42. }
43.
44. @android.view.RemotableViewMethod
45. public void setDurationBase(long durationBase) {
46.&n
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>