Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 警报对话框链接但保持文本为白色_Android_Fonts_Colors_Android Alertdialog_Linkify - Fatal编程技术网

Android 警报对话框链接但保持文本为白色

Android 警报对话框链接但保持文本为白色,android,fonts,colors,android-alertdialog,linkify,Android,Fonts,Colors,Android Alertdialog,Linkify,您好,我正在使用以下代码链接电子邮件地址和URL,这正是我所需要的工作,但如果您单击URL和电子邮件之外的任何位置,则未链接的白色文本将变为黑色,无法阅读。这不是什么大不了的事,但只是一些令人讨厌的事情。如果您能在格式化未链接文本onclick的颜色方面提供任何帮助,我们将不胜感激 final SpannableString s = new SpannableString("Some text here before link http://www.google.com

您好,我正在使用以下代码链接电子邮件地址和URL,这正是我所需要的工作,但如果您单击URL和电子邮件之外的任何位置,则未链接的白色文本将变为黑色,无法阅读。这不是什么大不了的事,但只是一些令人讨厌的事情。如果您能在格式化未链接文本onclick的颜色方面提供任何帮助,我们将不胜感激

            final SpannableString s = new SpannableString("Some text here before link http://www.google.com some more text then email fake@fake.com");
        Linkify.addLinks(s, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
        final AlertDialog d = new AlertDialog.Builder(MainMethod.this)
            .setPositiveButton(android.R.string.ok, null)
            .setIcon(R.drawable.about)
            .setTitle(R.string.about_title)
            .setMessage( s )
            .create();
        d.show();
        ((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
因此,下面的文本“链接之前的一些文本,然后是电子邮件”在对话框中显示为白色,但按下时变为黑色

编辑:

爪哇

XML


这可能不是正确的方法,但如果显式设置textColor属性,则可以绕过此问题

<TextView android:id="@+id/text1" 
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content" 
    android:autoLink="all"
    android:textColor="#ffffff"/>


如果我没有提醒您在设置文本颜色时使用,那我就是失职了,但它确实存在。

在xml文本视图中设置此选项

android:textColor="@android:color/secondary_text_dark_nodisable"
另见

<TextView android:id="@+id/text1" 
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content" 
    android:autoLink="all"
    android:textColor="#ffffff"/>
android:textColor="@android:color/secondary_text_dark_nodisable"