当前位置: 首页 > 知识库问答 >
问题:

在XML中自定义滚动视图上inflating类时出错?

吴腾
2023-03-14

我有一个使用 Mono Droid 构建的应用程序。我正在尝试制作一个无尽的滚动视图,以便我的用户可以滚动到底部并加载更多项目。这是我正在使用的类

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);
    }
}

这是我的xml文件。我从Java转换了所有这些代码,所以可能有什么地方我做错了。

 <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>

这是我的错误日志

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

在birds view . getfromparse . oncreate(Android。OS.Bundle) [0x00016]在Android的c:\ Users \ New User \ Desktop \ birds view \ birds view \ birds view \ getfromparse . cs:40中。app . activity . n _ OnCreate _ land roid _ OS _ Bundle _(intptr,int ptr,int ptr)[0x 00011]in/Users/builder/data/lanes/Mono droid-mlion-Mono droid-4.18-series/3b7ef 0 a 7/source/Mono droid/src/Mono。Android/平台/Android-19/src/generated/Android。App.Activity.cs:2179 at at(包装器动态方法)object . 06 c 20 e 74-6 EEC-438 c-a399-394 abf 9 BCD 74(intptr,int ptr,intptr) at托管异常堆栈跟踪结束-at Android . view . inflate exception:二进制XML文件行#1:使类com膨胀时出错。鸟瞰。鸟瞰。无限卷轴

位于android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)

共有2个答案

史默
2023-03-14

只需要简单地改变这些功能

 public EndlessScroll (Context context) 
    {
       super(context);
        init();
    }

    public EndlessScroll(Context context, AttributeSet attrs) 
    {

        super(context, attrs);
        init();

    }

    public EndlessScroll(Context context, AttributeSet attrs, int defStyle) 
    {
         super(context, attrs, defStyle);
        init();
    }
汪凌
2023-03-14

我让这个工作。显然你需要像这样命名 xml

<BirdsIView.EndlessScroll

代替

<com.BirdsIView.BirdsIView.EndlessScroll
 类似资料:
  • 我试着在谷歌和专门的论坛上搜索这个问题,但什么也没找到。 我的问题是:我有一个带代表的列表视图,根据Qt指南从C模型中读取数据。 当项目超出可见区域时,我不能使用滚动条,但我会得到如下结果: 其中3点将被启用/禁用,以告诉列表可以根据视图中的项目数量向上或向下滚动。 总之,它就像一个定制的滚动条。 你对实现这种行为有什么建议吗?或者我可以看看哪里?谢谢你。克里斯蒂亚诺

  • 我用最小SDK 15和目标23构建了一个应用程序,我在中有不同的视图。Apps在android版本=>5.0上运行良好,但在android版本<5.0上崩溃,出现以下错误消息 下面是我的的代码: list_item_text.xml Build.Gradle

  • 我已经检查了所有这些UITableView,是否让页脚停留在屏幕底部? tableFooterView属性不会修复表视图底部的页脚 iOS-ViewForFooterInstruction粘贴到UITableView的底部 在UITableView中实现页脚的正确方法 类似的问题,但不幸的是我的问题还没有解决。 我必须实现一个自定义的页眉和页脚视图,里面有按钮。我已经用.nib文件创建了单独的UI

  • 我有一个问题与自动滚动在滚动视图。 在我的例子中,有两个Recyclerview。第一个循环视图,水平滚动,第二个垂直滚动。第一个循环视图仅用于拖动,第二个循环视图只用于拖放。两个循环视图都在ScrollView中,所以我在第二个循环视图中禁用了垂直滚动。我在第二个Recyclerview的项目中添加了DragListener。每个项目都有一个拖动侦听器,因此我在拖放项目时添加/替换项目。 所以我

  • 我有一个片段,我在其中膨胀“Fragment\u board.xml”: 如您所见,fragment\u board包含一个自定义视图“BoardView”,我想从中加载以下“view\u board.xml”: 我的自定义视图包含两个滚动视图(我使用它进行平移),我希望能够在其他布局中重复使用它。BoardView扩展了外部(垂直)滚动视图,如下所示: 当我独立使用它时,它会膨胀得很好,我可以在

  • 提前致谢 下面是我的plugin.xml