HoloEverywhere布局文件夹中充满了资源错误?

时间:2013-03-21 15:37:30

标签: android android-holo-everywhere

我在我的项目中使用ActionBarSherlock和HoloEverywhere作为库,突然间HoloEverywhere开始变得混乱。

我做了一个像这样的AlertDialog:

AlertDialog.Builder alert = new AlertDialog.Builder(DomaCareDetailViewActivity.this)
    .setTitle(R.string.edit_service)
    .setItems(R.array.edit_service_array, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
                //tested and working code
            });
alert.create();
alert.show();

但是“create”行会抛出异常:

03-21 17:05:35.167: E/AndroidRuntime(25499): FATAL EXCEPTION: main
03-21 17:05:35.167: E/AndroidRuntime(25499): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.LayoutInflater.tryCreateView(LayoutInflater.java:359)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.LayoutInflater.onCreateView(LayoutInflater.java:308)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:287)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:272)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.LayoutInflater.inflate(LayoutInflater.java:267)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.internal.AlertController$AlertParams.createListView(AlertController.java:143)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.internal.AlertController$AlertParams.apply(AlertController.java:129)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.app.AlertDialog$Builder.create(AlertDialog.java:60)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at com.invian.domacare.task.DomaCareDetailViewActivity$20.onClick(DomaCareDetailViewActivity.java:1004)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.View.performClick(View.java:4084)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.View$PerformClick.run(View.java:16966)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.os.Handler.handleCallback(Handler.java:615)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.os.Looper.loop(Looper.java:137)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.app.ActivityThread.main(ActivityThread.java:4931)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at java.lang.reflect.Method.invokeNative(Native Method)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at java.lang.reflect.Method.invoke(Method.java:511)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at dalvik.system.NativeStart.main(Native Method)
03-21 17:05:35.167: E/AndroidRuntime(25499): Caused by: java.lang.reflect.InvocationTargetException
03-21 17:05:35.167: E/AndroidRuntime(25499):    at java.lang.reflect.Constructor.constructNative(Native Method)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-21 17:05:35.167: E/AndroidRuntime(25499):    ... 24 more
03-21 17:05:35.167: E/AndroidRuntime(25499): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01007a a=-1}
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.content.res.Resources.loadDrawable(Resources.java:1921)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at android.widget.ListView.<init>(ListView.java:153)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.widget.ListView.<init>(ListView.java:205)
03-21 17:05:35.167: E/AndroidRuntime(25499):    at org.holoeverywhere.widget.ListView.<init>(ListView.java:200)
03-21 17:05:35.167: E/AndroidRuntime(25499):    ... 27 more

我将源代码放在HoloEverywhere的com.holoeverywhere.internal.AlertController中,第143行出了问题:

final ListView listView = (ListView) mInflater
    .inflate(dialog.mListLayout, null);

检查mListLayout的初始化使我进入第383行:

mListLayout = a.getResourceId(R.styleable.AlertDialog_listLayout,
    R.layout.select_dialog_holo);

这是我得到的。我找不到“R.styleable.AlertDialog”,但由于AlertDialog.create()在我的项目中抛出异常,我确信这就是问题所在。但是,select_dialog_holo.xml文件确实存在各种错误:

Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

Failed to convert ?listDividerAlertDialog into a drawable
Couldn't find theme resource listDividerAlertDialog for the current theme

任何人对如何解决这个问题都有任何想法?

编辑:通过HoloEverywhere布局文件夹,我注意到有大量这类错误。例如,simple_list_item_1给了我几个“找不到资源”错误以及一些“listPreferredPaddingLeft / Right / etc in attribute paddingLeft is not valid format”错误。

0 个答案:

没有答案