我正在扩展 Application 类并初始化 admob,如下所示:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileAds.initialize(getApplicationContext(), getString(R.string.admob_app_id));
}
}
Run Code Online (Sandbox Code Playgroud)
但是 MobileAds.initialize 方法在我的 moto e2(API 23)中崩溃,而在我的 op3t(API 26)中工作正常。以下是崩溃的堆栈竞争:
I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:11020
I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 11020
D/DynamitePackage: Instantiated singleton DynamitePackage.
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
V/ConnectivityManager: isActiveNetworkMetered() returns:false
I/WebViewFactory: Loading com.google.android.webview version 71.0.3578.99 (code 357809900)
I/cr_LibraryLoader: Time to load native libraries: 2 ms (timestamps 315-317)
I/chromium: [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = …Run Code Online (Sandbox Code Playgroud) 这是我的布局 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" />
Run Code Online (Sandbox Code Playgroud)
它在回收视图中显示图像网格。我可以选择一堆图像并可以选择删除它们。以下是删除逻辑:
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();
}
Run Code Online (Sandbox Code Playgroud)
我希望在删除操作进行时进度条显示在前台。但它只是不显示。任何帮助将不胜感激。
android android-layout android-progressbar progress-bar android-recyclerview