2016-08-09 14 views
10

Chciałbym pokazać pasek postępu, gdy ładuje się internetowa wersja przeglądarki Android i użyłem Activity.setProgess (int).Activity.setProgress (int progress) jest przestarzałe

dokumentacja Android mówi setProgress (int postęp) została zaniechana na poziomie API 24. Nie jest już obsługiwana począwszy API 21.

Więc, co należy używać zamiast pokazać postęp gdy WebView się ładuje?

Odpowiedz

1

Pasek narzędzi narzędzia z paskiem postępu lub pokrętłem.

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar_actionbar" 
    style="@style/HeaderBar" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="?actionBarSize" 
    android:visibility="visible" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:popupTheme="@style/ActionBarPopupThemeOverlay" 
    app:theme="@style/ActionBarThemeOverlay" 
    > 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:gravity="right" 
     android:divider="?android:dividerVertical" 
     android:dividerPadding="8dp" 
     android:orientation="horizontal" 
     android:showDividers="beginning|middle"> 

     <ProgressBar 
      style="@style/Widget.AppCompat.ProgressBar.Horizontal" 
      android:id="@+id/toolbarProgressBar" 
      android:visibility="gone" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true"/> 
    </RelativeLayout> 
</android.support.v7.widget.Toolbar> 

Następnie znajdź to w widoku i zaktualizuj.

ProgressBar progressBar = (ProgressBar)findViewById(R.id.toolbarProgressBar); 
progressBar.setIndeterminate(false); 
progressBar.setProgress(x);