2015-05-15 138 views
0

我使用PagerSlidingTabStrip-for-Xamarin.Android 材料傳呼機滑動的拉帶材Xamarin.Android LIB在PagerSlidingTabStrip爲xamarin InflateException

我導入PagerSlidingTabStrip lib添加到我的解決方案(使用vs2013),並添加到XML com.refractored.PagerSlidingTabStrip

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:minWidth="25px" 
    android:minHeight="25px"> 
    <com.refractored.PagerSlidingTabStrip 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:pstsPaddingMiddle="true" 
     app:pstsDividerWidth="1dp" 
     app:pstsDividerPadding="12dp" 
     app:pstsDividerColor="#50FFFFFF" /> 
<!--Change this to true if you want to center items--> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     tools:context=".MainActivity" /> 
</LinearLayout> 

但InflateException中的setContentView 「com.refractored.PagerSlidingTabStrip」

05-15 14:26:59.848 D/Mono (27464): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so'). 
05-15 14:26:59.848 D/Mono (27464): Searching for '__android_log_print'. 
05-15 14:26:59.848 D/Mono (27464): Probing '__android_log_print'. 
05-15 14:26:59.848 D/Mono (27464): Found as '__android_log_print'. 
05-15 14:26:59.863 I/MonoDroid(27464): UNHANDLED EXCEPTION: 
05-15 14:26:59.878 I/MonoDroid(27464): Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown. 
05-15 14:26:59.878 I/MonoDroid(27464): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <IL 0x00011, 0x00068> 
05-15 14:26:59.878 I/MonoDroid(27464): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896 
05-15 14:26:59.878 I/MonoDroid(27464): at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4763 
05-15 14:26:59.878 I/MonoDroid(27464): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380 
05-15 14:26:59.878 I/MonoDroid(27464): at (wrapper dynamic-method) object.fc7251ee-439d-41fd-9acb-83d045358433 (intptr,intptr,intptr) <IL 0x00017, 0x00043> 
05-15 14:26:59.878 I/MonoDroid(27464): --- End of managed exception stack trace --- 
05-15 14:26:59.878 I/MonoDroid(27464): android.view.InflateException: Binary XML file line #1: Error inflating class com.refractored.PagerSlidingTabStrip 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
05-15 14:26:59.878 I/MonoDroid(27464): at dalvik.system.Na05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Activity.setContentView(Activity.java:1924) 
05-15 14:26:59.878 I/MonoDroid(27464): at scrollmenu.MainActivity.n_onCreate(Native Method) 
05-15 14:26:59.878 I/MonoDroid(27464): at scrollmenu.MainActivity.onCreate(MainActivity.java:28) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Activity.performCreate(Activity.java:5206) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.access$700(ActivityThread.java:140) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.os.Handler.dispatchMessage(Handler.java:99) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.os.Looper.loop(Looper.java:137) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.app.ActivityThread.main(ActivityThread.java:4946) 
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Method.invokeNative(Native Method) 
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Method.invoke(Method.java:511) 
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036) 
05-15 14:26:59.878 I/MonoDroid(27464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803) 
05-15 14:26:59.878 I/MonoDroid(27464): at dalvik.system.NativeStart.main(Native Method) 
05-15 14:26:59.878 I/MonoDroid(27464): Caused by: java.lang.reflect.InvocationTargetException 
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Constructor.constructNative(Native Method) 
05-15 14:26:59.878 I/MonoDroid(27464): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
05-15 14:26:59.878 I/MonoDroid(27464): ... 23 more 
05-15 14:26:59.878 I/MonoDroid(27464): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01009c a=-1} 
05-15 14:26:59.878 I/MonoDroid(27464): at android.content.res.Resources.loadDrawable(Resources.java:2001) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.View.<init>(View.java:3444) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.view.ViewGroup.<init>(ViewGroup.java:432) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.FrameLayout.<init>(FrameLayout.java:101) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.HorizontalScrollView.<init>(HorizontalScrollView.java:202) 
05-15 14:26:59.878 I/MonoDroid(27464): at android.widget.HorizontalScrollView.<init>(HorizontalScrollView.java:198) 
05-15 14:26:59.878 I/MonoDroid(27464): at com.refractored.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:38) 
05-15 14:26:59.878 I/MonoDroid(27464): ... 26 more 
An unhandled exception occured. 

05-15 14:27:01.188 E/mono (27464): 
05-15 14:27:01.188 E/mono (27464): Unhandled Exception: 
05-15 14:27:01.188 E/mono (27464): Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown. 
05-15 14:27:01.188 E/mono (27464): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <IL 0x00011, 0x00068> 
05-15 14:27:01.188 E/mono (27464): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896 
05-15 14:27:01.188 E/mono (27464): at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4763 
05-15 14:27:01.188 E/mono (27464): at ScrollMenu.MainActivity.OnCreate (Android.OS.Bundle) [0x00009] in d:\j.vso\bbalde\android\ScrollMenu\ScrollMenu\MainActivity.cs:22 
05-15 14:27:01.188 E/mono (27464): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380 
05-15 14:27:01.188 E/mono (27464): at (wrapper dynamic-method) object.fc7251ee-439d-41fd-9acb-83d045358433 (intptr,intptr,intptr) <IL 0x00017, 0x00043> 
05-15 14:27:01.188 E/mono (27464): 
05-15 14:27:01.188 E/mono (27464): --- End of managed exception stack trace --- 
05-15 14:27:01.188 E/mono (27464): android.view.InflateException: Binary XML file line #1: Error inflating class com.refractored.PagerSlidingTabStrip 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
05-15 14:27:01.188 E/mono (27464): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
05-15 14:27:01.188 E/mono (27464): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308) 
05-15 14:27:01.188 E/mono (27464): at android.app.Activity.setContentView(Activity.java:1924) 
05-15 14:27:01.188 E/mono (27464): at scrollmenu.MainActivity.n_onCreate(Native Method) 
05-15 14:27:01.188 E/mono (27464): at scrollmenu.MainActivity.onCreate(MainActivity.java:28) 
05-15 14:27:01.188 E/mono (27464): at android.app.Activity.performCreate(Activity.java:5206) 
05-15 14:27:01.188 E/mono (27464): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 

活動性可CA ll上的方法
所以它沒有連接庫..?

回答

1

如果使用MvvmCross框架必須在安裝類註冊PagerSlidingTabStrip組件:

public class Setup : MvxAndroidSetup 
{ 
    protected override IList<Assembly> AndroidViewAssemblies { 
     get { 
      var assemlies = base.AndroidViewAssemblies; 
      assemlies.Add(typeof(ViewPager).Assembly); 
      assemlies.Add(typeof(PagerSlidingTabStrip).Assembly); 
      return assemlies; 
     } 
    } 
}