本文介绍了帐户preferences名单上preference崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试使用如 SampleSyncAdapter 教程做了AccountAuthenticator东西创建的帐户类型。我现在想获得帐户preferences工作。

I have created an account type using the AccountAuthenticator stuff as done in the SampleSyncAdapter tutorial. I am now trying to get account preferences working.

我添加了这行安卓帐户preferences =@ XML / account_ preferences我的帐户认证和account_ preferences.xml看起来像这样:

I have added the line android:accountPreferences="@xml/account_preferences" to my account-authenticator and account_preferences.xml looks like so:

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/alum_settings_title"/>

<CheckBoxPreference
    android:key="sync_alum"
    android:title="@string/sync_alum"
    android:summaryOn="@string/sync_alum_check"
    android:summaryOff="@string/sync_alum_nocheck"/>

<ListPreference
    android:key="sync_alum_since"
    android:title="@string/alum_years"
    android:entries="@array/years"
    android:entryValues="@array/years"
    android:dependency="sync_alum"/>
</PreferenceScreen>

该复选框,preference工作完全像它应该,但名单preference崩溃,整个系统具有以下消息:

The checkbox preference works exactly like it should but the ListPreference crashes the entire system with the following message:

05-14 22:32:16.794: ERROR/AndroidRuntime(63): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

我得到同样的错误与EditText上preference和对话preference的自定义子类,我创建。

I get the same error with EditTextPreference and with the custom subclass of DialogPreference I created.

推荐答案

有关咧嘴一笑,尝试的摧毁你的 preferenceCategory 。这不是在做你多好原样反正,因为它不是任何包装preferences。我怀疑这是你的问题,但它很奇怪我唯一的XML看看。

For grins, try nuking your PreferenceCategory. It's not doing you much good as-is anyway, since it's not wrapping any preferences. I doubt this is your problem, but it's the only thing odd I see with the XML.

否则,该异常screans的Andr​​oid虫对我来说,如果你能创建重现该错误的项目,张贴和这个信息来的。

Otherwise, that exception screans "Android bug" to me, so if you can create a project that reproduces the error, post it and this info to http://b.android.com.

这篇关于帐户preferences名单上preference崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 05:22