2014-04-09 60 views
0

我試圖實施Actionbar-PullToRefresh庫到我的項目。遵循指南,但無法通過它。NoSuchMethodError實現PullToRefresh進入ListFragment

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),但沒有在這個片段中使用它,但是錯誤指向代碼中的ActionBarPullToRefresh行。

我錯過了什麼?

回答

1

如果您使用gradle,請嘗試刪除build.gradle文件中對smoothprogressbar的依賴關係。
對actionbarpulltorefresh的依賴關係也會導入smootprogressbar。
我有同樣的問題,併爲我工作。

0

ActionBar-PullToRefresh 0.9.3不支持SmoothProgressBar 0.4.0。 使用必須使用舊版本的SmoothProgressBar 0.2.2。