Android 進度條顯示在標(biāo)題欄的實現(xiàn)方法
更新時間:2017年01月04日 16:45:46 作者:大隊書記郭
android進度條顯示在標(biāo)題欄的實現(xiàn)方法,大概分文xml文件和java文件,具體代碼內(nèi)容大家可以通過本文學(xué)習(xí)下
好吧,先給大家展示效果圖:
xml文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 顯示"/> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="隱藏"/> </LinearLayout>
Java文件:
package com.imooc.progressbarr; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; public class MainActivity extends Activity { private Button btn1; private Button btn2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //設(shè)置窗口特征:啟用顯示進度的進度條 requestWindowFeature(Window.FEATURE_PROGRESS); //設(shè)置窗口特征:啟用不顯示進度的進度條 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_main); Button btn1=(Button)findViewById(R.id.button1); Button btn2=(Button)findViewById(R.id.button2); btn1.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub //顯示不帶進度的進度條 setProgressBarIndeterminateVisibility(true); //顯示不帶進度的進度條 setProgressBarVisibility(true); //設(shè)置進度條的進度 setProgress(4500); } }); btn2.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub //隱藏不帶進度的進度條 setProgressBarIndeterminateVisibility(false); //隱藏帶進度的進度條 setProgressBarVisibility(false); } }); } @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 進度條顯示在標(biāo)題欄的實現(xiàn)方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
- Android 下載文件通知欄顯示進度條功能的實例代碼
- Android編程實現(xiàn)顯示在標(biāo)題上的進度條功能【附源碼下載】
- Android實現(xiàn)標(biāo)題上顯示隱藏進度條效果
- android多線程斷點下載-帶進度條和百分比進度顯示效果
- Android多線程+單線程+斷點續(xù)傳+進度條顯示下載功能
- Android自定義多節(jié)點進度條顯示的實現(xiàn)代碼(附源碼)
- Android使用AsyncTask下載圖片并顯示進度條功能
- Android上傳文件到服務(wù)端并顯示進度條
- Android實現(xiàn)支持進度條顯示的短信備份工具類
- android實現(xiàn)動態(tài)顯示隱藏進度條
相關(guān)文章
Android為應(yīng)用添加數(shù)字角標(biāo)的簡單實現(xiàn)
應(yīng)用的角標(biāo)是用來標(biāo)記有多少條提醒沒讀,本篇文章主要介紹了Android為應(yīng)用添加角標(biāo)的簡單實現(xiàn),有興趣的可以了解一下。2017-04-04Android仿微信清理內(nèi)存圖表動畫(解決surfaceView屏幕閃爍問題)demo實例詳解
本文通過實例代碼給大家講解android仿微信清理內(nèi)存圖表動畫(解決surfaceView屏幕閃爍問題)的相關(guān)資料,本文介紹的非常詳細,具有參考借鑒價值,需要的朋友可以參考下2016-09-09Android教你如何發(fā)現(xiàn)APP卡頓的實現(xiàn)
這篇文章主要介紹了Android教你如何發(fā)現(xiàn)APP卡頓的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11