Android 進(jìn)度條顯示在標(biāo)題欄的實現(xiàn)方法
更新時間:2017年01月04日 16:45:46 作者:大隊書記郭
android進(jìn)度條顯示在標(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è)置窗口特征:啟用顯示進(jìn)度的進(jìn)度條
requestWindowFeature(Window.FEATURE_PROGRESS);
//設(shè)置窗口特征:啟用不顯示進(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)題欄的實現(xiàn)方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
- Android 下載文件通知欄顯示進(jìn)度條功能的實例代碼
- Android編程實現(xiàn)顯示在標(biāo)題上的進(jìn)度條功能【附源碼下載】
- Android實現(xiàn)標(biāo)題上顯示隱藏進(jìn)度條效果
- android多線程斷點下載-帶進(jìn)度條和百分比進(jìn)度顯示效果
- Android多線程+單線程+斷點續(xù)傳+進(jìn)度條顯示下載功能
- Android自定義多節(jié)點進(jìn)度條顯示的實現(xiàn)代碼(附源碼)
- Android使用AsyncTask下載圖片并顯示進(jìn)度條功能
- Android上傳文件到服務(wù)端并顯示進(jìn)度條
- Android實現(xiàn)支持進(jìn)度條顯示的短信備份工具類
- android實現(xiàn)動態(tài)顯示隱藏進(jìn)度條
相關(guān)文章
Android?Flutter使用本地數(shù)據(jù)庫編寫備忘錄應(yīng)用
這篇文章主要為大家詳細(xì)介紹了Android?Flutter如何使用本地數(shù)據(jù)庫實現(xiàn)編寫簡單的備忘錄應(yīng)用,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-03-03
Android Studio徹底刪除項目 Android Studio徹底刪除Module
這篇文章主要為大家詳細(xì)介紹了Android Studio徹底刪除項目,Android Studio徹底刪除Module,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-04-04
Android開發(fā)實現(xiàn)TextView超鏈接5種方式源碼實例
這篇文章主要介紹了Android開發(fā)實現(xiàn)TextView超鏈接5種方式源碼實例,需要的朋友可以參考下2020-03-03
Android ListView 和ScroolView 出現(xiàn)onmeasure空指針的解決辦法
這篇文章主要介紹了Android ListView 和ScroolView 出現(xiàn)onmeasure空指針的解決辦法的相關(guān)資料,需要的朋友可以參考下2017-02-02
Android如何利用svg實現(xiàn)可縮放的地圖控件
這篇文章主要給大家介紹了關(guān)于Android如何利用svg實現(xiàn)可縮放的地圖控件的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2022-01-01

