首页 > 代码库 > 安卓学习第21课——TitlerogressBar

安卓学习第21课——TitlerogressBar

<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">    <Button        android:id="@+id/bn1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentLeft="true"        android:layout_alignParentTop="true"        android:text="显示" />    <Button        android:id="@+id/bn2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentTop="true"        android:layout_centerHorizontal="true"        android:text="隐藏" />    </RelativeLayout>
package com.example.titleprogressbar;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.widget.Button;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        //设置窗口特征,启用显示进度的进度条        requestWindowFeature(Window.FEATURE_PROGRESS);        //设置窗口特征,启用不显示进度的进度条        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);        setContentView(R.layout.activity_main);        Button bn1=(Button) findViewById(R.id.bn1);        Button bn2=(Button) findViewById(R.id.bn2);        bn1.setOnClickListener(new OnClickListener(){            @Override            public void onClick(View v) {            //显示不带进度的进度条                setProgressBarIndeterminateVisibility(true);                //显示带进度的进度条                setProgressBarVisibility(true);                //设置进度条的进度                setProgress(4500);            }                    });        bn2.setOnClickListener(new OnClickListener(){            @Override            public void onClick(View v) {                //隐藏不带进度的进度条                setProgressBarIndeterminateVisibility(false);                //隐藏带进度的进度条                setProgressBarVisibility(false);                            }                    });    }}

 

安卓学习第21课——TitlerogressBar