Android 進(jìn)度條顯示在標(biāo)題欄的實(shí)現(xiàn)方法
好吧,先給大家展示效果圖:
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è)置窗口特征:?jiǎn)⒂蔑@示進(jìn)度的進(jìn)度條 requestWindowFeature(Window.FEATURE_PROGRESS); //設(shè)置窗口特征:?jiǎn)⒂貌伙@示進(jìn)度的進(jìn)度條 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 //顯示不帶進(jìn)度的進(jìn)度條 setProgressBarIndeterminateVisibility(true); //顯示不帶進(jìn)度的進(jìn)度條 setProgressBarVisibility(true); //設(shè)置進(jìn)度條的進(jìn)度 setProgress(4500); } }); btn2.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub //隱藏不帶進(jìn)度的進(jìn)度條 setProgressBarIndeterminateVisibility(false); //隱藏帶進(jìn)度的進(jìn)度條 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 進(jìn)度條顯示在標(biāo)題欄的實(shí)現(xiàn)方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- Android 下載文件通知欄顯示進(jìn)度條功能的實(shí)例代碼
- Android編程實(shí)現(xiàn)顯示在標(biāo)題上的進(jìn)度條功能【附源碼下載】
- Android實(shí)現(xiàn)標(biāo)題上顯示隱藏進(jìn)度條效果
- android多線程斷點(diǎn)下載-帶進(jìn)度條和百分比進(jìn)度顯示效果
- Android多線程+單線程+斷點(diǎn)續(xù)傳+進(jìn)度條顯示下載功能
- Android自定義多節(jié)點(diǎn)進(jìn)度條顯示的實(shí)現(xiàn)代碼(附源碼)
- Android使用AsyncTask下載圖片并顯示進(jìn)度條功能
- Android上傳文件到服務(wù)端并顯示進(jìn)度條
- Android實(shí)現(xiàn)支持進(jìn)度條顯示的短信備份工具類
- android實(shí)現(xiàn)動(dòng)態(tài)顯示隱藏進(jìn)度條
相關(guān)文章
Android離線Doc文檔訪問(wèn)速度慢的有效解決方法
今天小編就為大家分享一篇關(guān)于Android離線Doc文檔訪問(wèn)速度慢的有效解決方法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-03-03Android為應(yīng)用添加數(shù)字角標(biāo)的簡(jiǎn)單實(shí)現(xiàn)
應(yīng)用的角標(biāo)是用來(lái)標(biāo)記有多少條提醒沒(méi)讀,本篇文章主要介紹了Android為應(yīng)用添加角標(biāo)的簡(jiǎn)單實(shí)現(xiàn),有興趣的可以了解一下。2017-04-04Android gradle打包并自動(dòng)上傳的方法
本篇文章主要介紹了Android gradle打包并自動(dòng)上傳的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-09-09Android仿微信清理內(nèi)存圖表動(dòng)畫(huà)(解決surfaceView屏幕閃爍問(wèn)題)demo實(shí)例詳解
本文通過(guò)實(shí)例代碼給大家講解android仿微信清理內(nèi)存圖表動(dòng)畫(huà)(解決surfaceView屏幕閃爍問(wèn)題)的相關(guān)資料,本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09分析Android常見(jiàn)的內(nèi)存泄露和解決方案
內(nèi)存泄漏(Memory Leak)是指程序中己動(dòng)態(tài)分配的堆內(nèi)存由于某種原因程序未釋放或無(wú)法釋放,造成系統(tǒng)內(nèi)存的浪費(fèi),導(dǎo)致程序運(yùn)行速度減慢甚至系統(tǒng)崩潰 (OOM) 等嚴(yán)重后果2021-06-06Android?應(yīng)用程序的啟動(dòng)流程示例詳解
這篇文章主要為大家介紹了Android?應(yīng)用程序的啟動(dòng)流程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03Android教你如何發(fā)現(xiàn)APP卡頓的實(shí)現(xiàn)
這篇文章主要介紹了Android教你如何發(fā)現(xiàn)APP卡頓的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11