سؤال

I'm trying to implement Actionbar-PullToRefresh library into my project. Followed the guide, but couldn't get through it.

XML layout:

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

Fragment:

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) {
   ...
}

...
}

I'm getting this error:

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)

What's weird is the error indicates it came from SmoothProgressBar which I have already implemented in my project (using version 0.4.0) but didn't use it in this Fragment, however the error is pointing to ActionBarPullToRefresh line in code.

What did I missed?

هل كانت مفيدة؟

المحلول

If you use gradle, try to delete the dependency to smoothprogressbar in your build.gradle file.
The dependency to actionbarpulltorefresh will import smootprogressbar too.
I had the same problem and that worked for me.

نصائح أخرى

ActionBar-PullToRefresh 0.9.3 does not support SmoothProgressBar 0.4.0. Use must use an older version SmoothProgressBar 0.2.2.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top