Android开发:如何在标题栏显示Android进度条?
我们本次来谈谈如何在标题栏显示进度条的问题。
Step1,新建Android项目Android-basic-1-ProgressBar,如下图所示。
Step2,,代码如下:
01
<?xml version="" encoding="utf-8"?>
02
03
<LinearLayout xmlns:android="http://schemas./apk/res/android"
04
android:orientation="vertical"
05
android:layout_width="match_parent"
06
android:layout_height="wrap_content">
07
08
<Button android:id="@+id/toggle"
09
android:layout_width="wrap_content"
10
android:layout_height="wrap_content"
11
android:text="***@string/progressbar_toggle" />
12
13
</LinearLayout>
在该布局中,出于演示的目的,只是放置了一下Button,用于触发是否显示进度条在标题栏上。
Step3:我们接下来看看主要实现方式,代码如下:
01
.;
02
03
import ;
04
import ;
05
import ;
06
import ;
07
import ;
08
09
public class ProgressBarActivityextends Activity {
10
11
private boolean mToggleIndeterminate =false;
12
13
***@Override
14
protected void onCreate(Bundle savedInstanceState) {
15
(savedInstanceState);
16
17
requestWindowFeature();
18
setContentView();
19
安卓开发教程 来自淘豆网m.daumloan.com转载请标明出处.