Progress dialog deprecated

Now that progress dialog is deprecated in API-26 (Oreo)
what is the best approach to show progress spinner

I tried this link nothing helped :
https://stackoverflow.com/questions/45373007/progressdialog-is-deprecated-what-is-the-alternate-one-to-use/45373142

Please help soon as I'm stuck.

Answers

  • DimChrisDimChris USMember ✭✭✭
    edited September 18

    ProgressDialog was deprecated in API level 26 .
    https://stackoverflow.com/questions/45351127/progressdialog-is-deprecated/45351516

         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:padding="13dp"
        android:layout_centerHorizontal="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
        <ProgressBar
            android:id="@+id/loader"
            android:layout_marginEnd="5dp"
            android:layout_width="45dp"
            android:layout_height="45dp" />
        <TextView
            android:layout_width="wrap_content"
            android:text="Loading..."
            android:textAppearance="?android:textAppearanceSmall"
            android:layout_gravity="center_vertical"
            android:id="@+id/loading_msg"
            android:layout_toEndOf="@+id/loader"
            android:layout_height="wrap_content" />
    
    </LinearLayout>
    
          private void setDialog(boolean show){
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            //View view = getLayoutInflater().inflate(R.layout.progress);
            builder.setView(R.layout.progress);
            Dialog dialog = builder.create();
            if (show)dialog.show();
            else dialog.dismiss();
        }
    
Sign In or Register to comment.