ActionbarSherlockBinding supportmenuinflater膨胀错误

时间:2014-11-06 14:09:01

标签: xamarin actionbarsherlock inflate-exception

我已将ActionBarSherlock.dll引用到我的项目中,现在我正在尝试在我的活动中使用它,但是一旦我使用SupportMenuInflater.Inflate就会崩溃:

> [AndroidRuntime] FATAL EXCEPTION: main [AndroidRuntime] Process:
> com.LokalGems.Droid.Beta, PID: 13033 [AndroidRuntime]
> android.view.InflateException: Binary XML file line #17: Error
> inflating class <unknown> [AndroidRuntime]    at
> android.view.LayoutInflater.createView(LayoutInflater.java:620)
> [AndroidRuntime]  at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
> [AndroidRuntime]  at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
> [AndroidRuntime]  at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
> [AndroidRuntime]  at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
> [AndroidRuntime]  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:492)
> [AndroidRuntime]  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:397)
> [AndroidRuntime]  at
> com.actionbarsherlock.widget.ActivityChooserView.<init>(ActivityChooserView.java:229)
> [AndroidRuntime]  at
> com.actionbarsherlock.widget.ActivityChooserView.<init>(ActivityChooserView.java:202)
> [AndroidRuntime]  at
> com.actionbarsherlock.widget.ActivityChooserView.<init>(ActivityChooserView.java:192)
> [AndroidRuntime]  at
> com.actionbarsherlock.widget.ShareActionProvider.onCreateActionView(ShareActionProvider.java:164)
> [AndroidRuntime]  at
> com.actionbarsherlock.internal.view.ActionProviderWrapper.onCreateActionView(ActionProviderWrapper.java:23)
> [AndroidRuntime]  at
> android.view.ActionProvider.onCreateActionView(ActionProvider.java:98)
> [AndroidRuntime]  at
> com.android.internal.view.menu.MenuItemImpl.getActionView(MenuItemImpl.java:583)
> [AndroidRuntime]  at
> com.android.internal.view.menu.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:161)
> [AndroidRuntime]  at
> com.android.internal.view.menu.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:438)
> [AndroidRuntime]  at
> com.android.internal.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1062)
> [AndroidRuntime]  at
> com.android.internal.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:87)
> [AndroidRuntime]  at
> com.android.internal.view.menu.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:216)
> [AndroidRuntime]  at
> com.android.internal.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:244)
> [AndroidRuntime]  at
> com.android.internal.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:956)
> [AndroidRuntime]  at
> com.android.internal.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:979)
> [AndroidRuntime]  at
> com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:479)
> [AndroidRuntime]  at
> com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:800)
> [AndroidRuntime]  at
> com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:221)
> [AndroidRuntime]  at
> android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
> [AndroidRuntime]  at
> android.view.Choreographer.doCallbacks(Choreographer.java:574)
> [AndroidRuntime]  at
> android.view.Choreographer.doFrame(Choreographer.java:543)
> [AndroidRuntime]  at
> android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
> [AndroidRuntime]  at
> android.os.Handler.handleCallback(Handler.java:733) [AndroidRuntime]
>   at android.os.Handler.dispatchMessage(Handler.java:95)
> [AndroidRuntime]  at android.os.Looper.loop(Looper.java:136)
> [AndroidRuntime]  at
> android.app.ActivityThread.main(ActivityThread.java:5001)
> [AndroidRuntime]  at java.lang.reflect.Method.invokeNative(Native
> Method) [AndroidRuntime]  at
> java.lang.reflect.Method.invoke(Method.java:515) [AndroidRuntime]     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
> [AndroidRuntime]  at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
> [AndroidRuntime]  at dalvik.system.NativeStart.main(Native Method)
> [AndroidRuntime] Caused by:
> java.lang.reflect.InvocationTargetException [AndroidRuntime]  at
> java.lang.reflect.Constructor.constructNative(Native Method)
> [AndroidRuntime]  at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> [AndroidRuntime]  at
> android.view.LayoutInflater.createView(LayoutInflater.java:594)
> [AndroidRuntime]  ... 37 more [AndroidRuntime] Caused by:
> android.content.res.Resources$NotFoundException: Resource is not a
> Drawable (color or path): TypedValue{t=0x2/d=0x7f01000f a=-1}
> [AndroidRuntime]  at
> android.content.res.Resources.loadDrawable(Resources.java:2068)
> [AndroidRuntime]  at
> android.content.res.TypedArray.getDrawable(TypedArray.java:602)
> [AndroidRuntime]  at android.view.View.<init>(View.java:3554)
> [AndroidRuntime]  at android.view.ViewGroup.<init>(ViewGroup.java:470)
> [AndroidRuntime]  at
> android.widget.FrameLayout.<init>(FrameLayout.java:101)
> [AndroidRuntime]  at
> android.widget.FrameLayout.<init>(FrameLayout.java:97)
> [AndroidRuntime]  ... 40 more

我正在使用ActionBarSherlock测试应用程序对其进行建模:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Widget;
using LokalGems.BL;
using Xamarin.ActionbarSherlockBinding;
using Xamarin.ActionbarSherlockBinding.App;
using Xamarin.ActionbarSherlockBinding.Views;
using SherlockActionBar = Xamarin.ActionbarSherlockBinding.App.ActionBar;
using ShareActionProvider = Xamarin.ActionbarSherlockBinding.Widget.ShareActionProvider;
using Android.App;

namespace LokalGems.Droid
{
    [Activity (Label = "LokalGemDetailsActivity")]          
    public class LokalGemDetailsActivity : SherlockActivity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
            int id = Intent.GetIntExtra ("data", 0);
            LokalGem lokalGem = LokalGems.BL.Managers.LokalGemManager.GetLokalGem(id);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.fragment_lokalgem_detail);

            ImageView lokalgems_photo = FindViewById<ImageView> (Resource.Id.lokalgem_detail_iv_picture);
            if (lokalGem != null) {
                int resID = RequestPictureID (lokalGem.Name);
                lokalgems_photo.SetImageResource (resID);
            }

            ImageView lokalgems_category = FindViewById<ImageView> (Resource.Id.lokalgem_detail_iv_categories_icon);
            ImageView lokalgems_likes = FindViewById<ImageView> (Resource.Id.lokalgem_detail_iv_likes);
            ImageView lokalgems_location = FindViewById<ImageView> (Resource.Id.lokalgem_detail_iv_location_icon);

            lokalgems_likes.SetImageResource (Resource.Drawable.likes);
            lokalgems_category.SetImageResource (Resource.Drawable.categories);
            lokalgems_location.SetImageResource (Resource.Drawable.location);

            TextView textView = FindViewById<TextView> (Resource.Id.lokalgem_detail_tv_history);
            textView.Text = lokalGem.History;
        }

我试图膨胀的XML文件(不是.axml)非常简单:(几乎与示例项目中的相同。

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/menu_item_share_action_provider_action_bar"
        android:showAsAction="always"
        android:title="hi"
        android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider" />
</menu>

任何人都知道忘记/做错了什么?

1 个答案:

答案 0 :(得分:0)

解决:

需要将项目的主题(在清单中)更改为&#34; @ style / Theme.Sherlock&#34;