我正在尝试将 Actionbar-PullToRefresh 库实现到我的项目中。按照指南,但无法通过它。
XML布局:
<uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ptr_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/clouds" >
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:dividerHeight="1dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@android:id/empty"
android:layout_centerInParent="true"
android:textAlignment="center" />
</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout>
片段:
public class LatestFragment extends ListFragment implements OnScrollListener, OnRefreshListener {
private PullToRefreshLayout mPullToRefreshLayout;
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewGroup viewGroup = (ViewGroup) view;
mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());
ActionBarPullToRefresh.from(getActivity())
.insertLayoutInto(viewGroup)
.theseChildrenArePullable(getListView(), getListView().getEmptyView())
.listener(this)
.setup(mPullToRefreshLayout);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
...
loadItemList(1);
}
@Override
public void onRefreshStarted(View view) {
loadItemList(1);
}
private void loadItemList(int page) {
...
}
...
}
我收到了这个错误:
04-09 18:23:35.739 12681-12681/kedai.cryptomarket.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoSuchMethodError: fr.castorflex.android.smoothprogressbar.SmoothProgressDrawable$Builder.width
at uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer.applyProgressBarSettings(DefaultHeaderTransformer.java:372)
at uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer.onViewCreated(DefaultHeaderTransformer.java:104)
at uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.<init>(PullToRefreshAttacher.java:120)
at uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout.createPullToRefreshAttacher(PullToRefreshLayout.java:223)
at uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh$SetupWizard.setup(ActionBarPullToRefresh.java:92)
at kedai.cryptomarket.app.fragment.drawer.LatestFragment.onViewCreated(LatestFragment.java:65)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:952)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:446)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5227)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
奇怪的是,错误表明它来自SmoothProgressBar
,我已经在我的项目中实现了(使用版本0.4.0),但没有在此片段中使用它,但错误指向{{ 1}}代码行。
我错过了什么?
答案 0 :(得分:1)
如果您使用gradle,请尝试删除build.gradle文件中smoothprogressbar的依赖项。
对actionbarpulltorefresh的依赖也将导入smootprogressbar
我有同样的问题,这对我有用。
答案 1 :(得分:0)
ActionBar-PullToRefresh 0.9.3不支持SmoothProgressBar 0.4.0。 使用必须使用旧版本SmoothProgressBar 0.2.2。