Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating class on custom scrollview in XML?

I have an app that I am building using Mono Droid. I am trying to make an endless scrollview so that my users can scroll to the bottom and have more items loaded. Here is the class that I am using

public class EndlessScroll : ScrollView
{ 
    public EndlessScroll (Context context) : base (context)
    {}

    public EndlessScroll(Context context, IAttributeSet attrs) : base(context, attrs)
    {}

    public EndlessScroll(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
    {}

    public interface OnScrollViewListener
    {
        void onScrollChanged(EndlessScroll v, int l, int t, int oldl, int oldt);
    }

    public  OnScrollViewListener mOnScrollViewListener;

    public void setOnScrollViewListener(OnScrollViewListener l) 
    {
        this.mOnScrollViewListener = l;
    }

    protected void onScrollChanged(int l, int t, int oldl, int oldt)
    {
        mOnScrollViewListener.onScrollChanged(this, l, t, oldl, oldt);
        base.OnScrollChanged(l, t, oldl, oldt);
    }
}

Here is my xml file. I converted all this code from Java so there may be something that I am doing wrong.

 <com.BirdsIView.BirdsIView.EndlessScroll
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="90"
    android:id="@+id/scrollView">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/viewDebug" />
</com.BirdsIView.BirdsIView.EndlessScroll>

Here is my error log

Android.Views.InflateException: Binary XML file line #1: Error inflating class com.BirdsIView.BirdsIView.EndlessScroll


at at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>

at Android.Runtime.JNIE nv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896

at BirdsIView.getFromParse.OnCreate (Android.OS.Bundle) [0x00016] in c:\Users\New User\Desktop\BirdsIView\BirdsIView\BirdsIView\getFromParse.cs:40 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.App.Activity.cs:2179 at at (wrapper dynamic-method) object.06c20e74-6eec-438c-a399-394abf9bcd74 (intptr,intptr,intptr) at --- End of managed exception stack trace --- at android.view.InflateException: Binary XML file line #1: Error inflating class com.BirdsIView.BirdsIView.EndlessScroll

at at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)

like image 258
Kirasoft Avatar asked Nov 18 '25 04:11

Kirasoft


1 Answers

I got this to work. Apparently you need to name the xml like so

<BirdsIView.EndlessScroll

instead of

<com.BirdsIView.BirdsIView.EndlessScroll
like image 152
Kirasoft Avatar answered Nov 19 '25 20:11

Kirasoft