我使用AlertDialog提醒用户确认删除.我检查了我的设备(Android 5.1),它显示得很好
但在另一台设备上(也运行Android 5.1),对话框错过了正面和负面按钮.
我查了一下,发现设备发生这个问题有中等分辨率(960x540,854x480).
解决方案是否涉及此问题?如果没有,你能告诉我原因以及如何解决这个问题吗?
我的显示对话框代码:
public static final Dialog yesNoDialog(Context context,
String message,
DialogInterface.OnClickListener yesAction, DialogInterface.OnClickListener noAction) {
AlertDialog.Builder builder = new AlertDialog.Builder(context,R.style.todoDialogLight);
builder.setTitle(context.getString(R.string.app_name))
.setMessage(message)
.setCancelable(false)
.setPositiveButton("YES", yesAction)
.setNegativeButton("NO", noAction);
return builder.create();
}
Run Code Online (Sandbox Code Playgroud)
和styles.xml
<style name="todoDialogLight" parent="Theme.AppCompat.Light.Dialog">
<!-- Used for the buttons -->
<item name="colorAccent">@color/colorPrimaryDark</item>
<item name="android:textStyle">bold</item>
<!-- Used for the title and text -->
<item name="android:textColorPrimary">@color/colorText</item>
<!-- Used for the background -->
<!-- <item name="android:background">#4CAF50</item>-->
<item name="android:fontFamily">sans-serif</item>
<item name="android:windowAnimationStyle">@style/RemindDialogAnimation</item>
<item name="android:layout_width">@dimen/width_remind_dialog</item>
<item name="android:layout_height">wrap_content</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我记得旧的 Android Studio 版本可以从翻译编辑器复制 (CTRT+C) 所有文本值,然后粘贴 (CTRT+V) 到 Google Sheet。但这是不可能的,直到 Android Studio 3.2 。我们如何将所有文本值导出到 Google Sheet(反之亦然)以支持翻译?
我已将我的应用程序迁移到 AndroidX。如果我禁用 proguard,一切正常。如果我启用 proguard,应用程序可以成功构建但在我打开应用程序时崩溃。
207) 在 android.app.ActivityThread.main(ActivityThread.java:7539) 在 java.lang.reflect.Method.invoke(Native Method) 在 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java: 524) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 2019-07-25 07:14:46.903 1437-1437/? E/LoadedApk:无法实例化 appComponentFactory java.lang.ClassNotFoundException:在路径上找不到类“androidx.core.app.CoreComponentFactory”:DexPathList[[] 14:46.903 1437-1437/? E/LoadedApk:无法实例化 appComponentFactory java.lang.ClassNotFoundException:在路径上找不到类“androidx.core.app.CoreComponentFactory”:DexPathList[[] 14:46.903 1437-1437/? E/LoadedApk:无法实例化 appComponentFactory java.lang.ClassNotFoundException:在路径上找不到类“androidx.core.app.CoreComponentFactory”:DexPathList[[]
我在下面尝试了一些解决方案,但没有帮助。
proguard-rules.pro
-保持类androidx.core.app.CoreComponentFactory { *; }
清单文件
工具:replace="android:appComponentFactory"
android:appComponentFactory="whatevestring"
有没有人和我一样的问题?以及你是如何解决的?谢谢你。
我有这样的越南文字:
String text = "Xin chào Vi?t Nam";
Run Code Online (Sandbox Code Playgroud)
我想将其转换为普通文本.我的期望结果:
String result = " "Xin chao Viet Nam";
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢.
请查看以下图片:
第一张图片是我做的布局,它在我的设备和其他测试设备上正常显示.第二张图片是我朋友设备上显示的布局,它是相反的.我不知道为什么,它只发生在少数设备上.
这是我在xml上的布局代码.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:auto="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.ComposeSmsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_action" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/padding_5">
<com.hnib.smslater.views.FlowLayout
android:id="@+id/layout_name_recipient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10"
android:fontFamily="sans-serif-light"
android:orientation="horizontal">
</com.hnib.smslater.views.FlowLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_10">
<com.hnib.smslater.views.ClearableAutoContactCompleteTextView
android:id="@+id/et_recipient"
android:layout_width="@dimen/width_et_contact"
android:layout_height="@dimen/height_et_default"
android:layout_centerVertical="true"
android:layout_marginTop="@dimen/margin_10"
android:background="@drawable/drawable_radius_gray_gray"
android:fontFamily="sans-serif-light"
android:hint="@string/to_"
android:imeOptions="actionDone"
android:padding="@dimen/padding_5"
android:textColorHint="@color/gray"
android:textSize="18sp"
android:textStyle="bold"
auto:displayPhotoIfAvailable="false"
auto:styleOfTypedLetters="bold"
auto:typeOfData="phone"
auto:typedLettersHaveDifferentStyle="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_5"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:fontFamily="sans-serif-light"
android:text="@string/message"
android:textColor="@color/gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_message_length"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我使用 WebView 并在下面的日志中崩溃
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at com.android.webview.chromium.Ap.getDefaultVideoPoster(WebViewContentsClientAdapter.java:565)
at org.chromium.android_webview.DefaultVideoPosterRequestHandler$$Lambda$0.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Run Code Online (Sandbox Code Playgroud)
在第一行,它在空指针上显示 Bitmap.getWidth() 但我没有在我的 webview 上使用任何位图。
下面是我的 webview 代码
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowContentAccess(true);
webSettings.setAllowFileAccess(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAppCacheEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
webView.addJavascriptInterface(new WebViewResizer(), "WebViewResizer");
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView webView, String url) {
super.onPageFinished(webView, url);
System.out.println("WEBVIEW LOAD PAGE FINISHED");
}
}); …Run Code Online (Sandbox Code Playgroud) 我使用 DatePickerDialog 允许用户选择一天。
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.TUESDAY);
new DatePickerDialog(this, dateListener, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show();
Run Code Online (Sandbox Code Playgroud)
我使用setFirstDayOfWeek方法将一周的开始日期设置为星期二,但对话框选择器始终在左侧显示星期一。
如何为 DatePickerDialog 设置一周的开始日期?