我正在尝试使用https://github.com/chrisbanes/Android-PullToRefresh/。我按照这个例子但得到了错误 java.lang.NoSuchFieldError:com.handmark.pulltorefresh.library.R $ id.pull_to_refresh_sub_text
这是我的网格:
<com.handmark.pulltorefresh.library.PullToRefreshGridView
xmlns:ptr="http://schemas.android.com/apk/res/com.abc.myproject"
android:id="@+id/gv_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="#00000000"
android:padding="4dp"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp"
android:gravity="center"
android:numColumns="3"
android:columnWidth="128px"
android:stretchMode="columnWidth"
ptr:ptrMode="pullDownFromTop"
ptr:ptrDrawable="@drawable/android" />
当我跑步时,我有上述异常。我将PullToRefresh添加为工作区中的另一个项目,并将其作为项目的库。我还添加了Jar文件。我认为错误是因为这条线 的xmlns:PTR = “http://schemas.android.com/apk/res/com.abc.myproject”
我跟踪代码,导致异常的行在LoadingLayout.java中: mSubHeaderText =(TextView)header.findViewById(R.id.pull_to_refresh_sub_text);
我做错了吗?
谢谢!
答案 0 :(得分:2)
Android SDK Tools r17增加了对库中自定义属性的自定义视图的支持。使用自定义属性的布局必须使用命名空间URI:
http://schemas.android.com/apk/res-auto
而不是包含应用包名称的URI。在构建时,此URI将替换为特定于应用程序的URI。
答案 1 :(得分:2)
我有同样的问题,
我所做的是修复它是从列表的底部到顶部移动对库的引用。我认为我引用的内容与R.java
中ID的生成相矛盾。
您可以在R.java
中搜索pull_to_refresh_sub_text
,以确保其已正确生成。