0
我有參考ActionBarSherlock.dll到我的項目,現在我想在我的活動使用它,但只要我使用SupportMenuInflater.Inflate崩潰:ActionbarSherlockBinding supportmenuinflater充氣錯誤
> [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
我「M從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),我嘗試膨脹是非常簡單的:(exectly一樣幾乎在示例項目
。<?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>
任何人都有什麼想法我忘了/做錯了什麼?