最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)戰(zhàn)教程第二篇之簡單實(shí)現(xiàn)兩種進(jìn)度條效果

 更新時間:2016年11月10日 11:05:52   作者:楊道龍  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)戰(zhàn)教程第二篇,簡單實(shí)現(xiàn)兩種進(jìn)度條效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例實(shí)現(xiàn)點(diǎn)擊按鈕模擬進(jìn)度條下載進(jìn)度,“下載”完成進(jìn)度條消失,供大家參考,具體內(nèi)容如下

代碼如下:
xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="vertical" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 > 
<TextView 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" 
 android:text="@string/hello" 
 /> 
<ProgressBar 
 android:id="@+id/firstBar" 
 style="?android:attr/progressBarStyleHorizontal" 
 android:layout_width="200dp" 
 android:layout_height="wrap_content" 
 android:visibility="gone" 
 /> 
<ProgressBar 
 android:id="@+id/secondBar" 
 style="?android:attr/progressBarStyle" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:visibility="gone" 
 /> 
<Button 
 android:id="@+id/myButton" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:text="begin" 
 /> 
</LinearLayout> 

Activity:

package ydl.progressbar; 
 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.ProgressBar; 
 
public class ProgressBarTest extends Activity { 
 /** Called when the activity is first created. */ 
 //聲明變量 
 private ProgressBar firstBar =null; 
 private ProgressBar secondBar = null; 
 private Button myButton = null; 
 private int i = 0 ; 
 @Override 
 public void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.main); 
  //根據(jù)控件的ID來取得代表控件的對象 
  firstBar = (ProgressBar)findViewById(R.id.firstBar); 
  secondBar = (ProgressBar)findViewById(R.id.secondBar); 
  myButton = (Button)findViewById(R.id.myButton); 
  myButton.setOnClickListener(new ButtonListener()); 
 } 
 class ButtonListener implements OnClickListener{ 
   
  @Override 
  public void onClick(View v) { 
   if(i == 0) 
   { 
    //設(shè)置進(jìn)度條處于可見的狀態(tài) 
    firstBar.setVisibility(View.VISIBLE); 
    firstBar.setMax(150);//手動設(shè)置最大值,默認(rèn)是100 
    secondBar.setVisibility(View.VISIBLE); 
   } 
   else if ( i < firstBar.getMax()){ 
    //設(shè)置主進(jìn)度條的當(dāng)前值 
    firstBar.setProgress(i); 
    //設(shè)置第二進(jìn)度條的當(dāng)前值 
    firstBar.setSecondaryProgress(i + 10); 
    //因為默認(rèn)的進(jìn)度條無法顯示進(jìn)行的狀態(tài) 
    //secondBar.setProgress(i); 
     
   } 
   else{ 
    //設(shè)置進(jìn)度條處于不可見狀態(tài) 
    firstBar.setVisibility(View.GONE); 
    secondBar.setVisibility(View.GONE); 
   } 
   i = i + 10 ; 
  } 
   
 } 
  
}

 以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫訪問實(shí)例

    Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫訪問實(shí)例

    下面小編就為大家分享一篇Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫訪問實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02
  • Android實(shí)現(xiàn)搖一搖功能

    Android實(shí)現(xiàn)搖一搖功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)搖一搖功能的相關(guān)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • 深入理解Android中的建造者模式

    深入理解Android中的建造者模式

    建造者模式將一個復(fù)雜的構(gòu)建與其表示相分離,使得同樣的構(gòu)建過程可以創(chuàng)建不同的表示。所以這篇文章主要介紹了Android中的建造者模式,有需要的朋友們可以參考借鑒。
    2016-09-09
  • 微信Android熱更新Tinker使用詳解(星空武哥)

    微信Android熱更新Tinker使用詳解(星空武哥)

    Tinker是微信官方的Android熱補(bǔ)丁解決方案,它支持動態(tài)下發(fā)代碼、So庫以及資源,讓應(yīng)用能夠在不需要重新安裝的情況下實(shí)現(xiàn)更新。當(dāng)然,你也可以使用Tinker來更新你的插件
    2017-09-09
  • Android中SoundPool的使用步驟實(shí)例

    Android中SoundPool的使用步驟實(shí)例

    今天小編就為大家分享一篇關(guān)于Android中SoundPool的使用步驟實(shí)例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • Android使用GPS獲取用戶地理位置并監(jiān)聽位置變化的方法

    Android使用GPS獲取用戶地理位置并監(jiān)聽位置變化的方法

    這篇文章主要介紹了Android使用GPS獲取用戶地理位置并監(jiān)聽位置變化的方法,實(shí)例分析了Android編程中GPS定位的實(shí)現(xiàn)與使用技巧,需要的朋友可以參考下
    2015-12-12
  • Android基于注解的6.0權(quán)限動態(tài)請求框架詳解

    Android基于注解的6.0權(quán)限動態(tài)請求框架詳解

    這篇文章主要介紹了Android基于注解的6.0權(quán)限動態(tài)請求框架詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-04-04
  • Android利用控制點(diǎn)的拖拽畫一個粽子

    Android利用控制點(diǎn)的拖拽畫一個粽子

    端午節(jié)就要到了,本文我們將利用控制點(diǎn)的拖拽式移動,動態(tài)調(diào)整位置來調(diào)整繪制一個簡單的粽子圖形,感興趣的小伙伴可以跟隨小編一起動手嘗試一下
    2022-05-05
  • Android中ListView結(jié)合CheckBox實(shí)現(xiàn)數(shù)據(jù)批量選擇(全選、反選、全不選)

    Android中ListView結(jié)合CheckBox實(shí)現(xiàn)數(shù)據(jù)批量選擇(全選、反選、全不選)

    這篇文章主要介紹了Android編程中ListView結(jié)合CheckBox實(shí)現(xiàn)批量選擇,包括實(shí)現(xiàn)全選、反選、全不選等操作,感興趣的小伙伴們可以參考一下
    2016-01-01
  • Android實(shí)現(xiàn)三段式滑動效果

    Android實(shí)現(xiàn)三段式滑動效果

    最近發(fā)現(xiàn)很多app都使用了三段式滑動,比如說高德的首頁和某寶等物流信息都是使用的三段式滑動方式,谷歌其實(shí)給了我們很好的2段式滑動,就是BottomSheet,所以這次我也是在這個原理基礎(chǔ)上做了一個小小的修改來實(shí)現(xiàn)我們今天想要的效果。
    2021-06-06

最新評論

紫云| 孝感市| 二连浩特市| 南乐县| 从江县| 沙湾县| 新巴尔虎左旗| 古交市| 永州市| 江阴市| 通化县| 额济纳旗| 漾濞| 新兴县| 武城县| 武城县| 和龙市| 乌拉特前旗| 若羌县| 明光市| 和平区| 介休市| 兴海县| 游戏| 滁州市| 合阳县| 民勤县| 寿阳县| 金塔县| 太湖县| 辽宁省| 清丰县| 西贡区| 通辽市| 剑川县| 房产| 个旧市| 阿克陶县| 色达县| 长沙县| 仙居县|