繁体   English   中英

Android 进度条未显示

[英]The Android Progress bar not showing up

这是我的布局 xml:

<RelativeLayout 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="match_parent"
android:background="@color/fragment_body"
android:fitsSystemWindows="true">

<include
    android:id="@+id/contextToolBar"
    layout="@layout/context_toolbar_layout" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/list1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/contextToolBar"
    android:scrollbarSize="5dp"
    android:scrollbarThumbVertical="@color/scrollbarColor"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<ProgressBar
    android:id="@+id/delete_progress"
    style="@style/Widget.AppCompat.ProgressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:visibility="gone" />

它在回收视图中显示图像网格。 我可以选择一堆图像并可以选择删除它们。 以下是删除逻辑:

public void deleteSelectedFiles(final Context context, final List<MediaModel> selectionList) {

    String confirmationMessage = getString(R.string.delete_confirm_message);

    new AlertDialog.Builder(context)
            .setTitle(getString(R.string.action_delete))
            .setMessage(confirmationMessage)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
                View progressBar = getActivity().findViewById(R.id.delete_progress);
                dialog.cancel();
                progressBar.setVisibility(View.VISIBLE);

                deleteFileList(selectionList, this.getActivity());

                progressBar.setVisibility(View.GONE);
            })
            .setNegativeButton(android.R.string.no, null).show();
}

我希望在删除操作进行时进度条显示在前台。 但它只是不显示。 任何帮助将不胜感激。

所以我以前遇到过这个问题。 就我而言,这是因为我在整个应用程序中使用了 Material Design 主题,所以我不得不使用特定的方向,它解决了我的问题。 你可以试试

<ProgressBar
                android:id="@+id/progressBarReady"
                style="@android:style/Widget.ProgressBar.Horizontal"
                android:layout_width="match_parent"
                android:layout_height="3dp"
                android:indeterminate="true"
                android:visibility="visible"/>

我有一个类似的问题。 就我而言,我使用 ProgressBar 作为 CoordinatorLayout 中的加载指示器。 在 Activity/Fragment - 在不同的点 - 基于可用的数据 - 即使用光标或来自网络,我需要调用mViewA.setVisibility(View.GONE)mViewB.setVisibility(View.VISIBLE) 当我为包括 ProgressBar 视图在内的视图正确设置这些时,它变得可见。

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

style="?android:attr/progressBarStyle"为我修复了它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM