2016-08-09 14 views
10

android webviewがロードされているときにプログレスバーを表示したいと思い、Activity.setProgess(int)を使用しました。Activity.setProgress(int progress)は非推奨です

Androidのドキュメントには、WebViewのがロードされたとき、私は進行状況を表示する代わりに何を使用する必要があり、もはやそう

API 21以降でサポートさでsetProgress(int型の進捗状況が)APIレベル24で廃止されました言いませんか?

答えて

1

プログレスバーまたはスピナーを備えたツールバーを実装します。

<?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> 

次に、あなたの視点でそれを見つけて更新してください。

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