Aspsine / IRecyclerView

IRecyclerView is a custom RecyclerView that supports pull-to-refresh, pull-to-loadmore, customize refresh header and loadmore footer, add header views and footer views.
730 stars 146 forks source link

ClassCastException: android.widget.LinearLayout cannot be cast to LoadMoreFooterView #10

Closed yanxinmiao closed 8 years ago

yanxinmiao commented 8 years ago

loadMoreFooterView = (LoadMoreFooterView) iRecyclerView.getLoadMoreFooterView();

这行竟然报这个错误,什么情况

Aspsine commented 8 years ago

The app:loadMoreFooterLayout attribute you set in xml is an instance of LinearLayout not LoadMoreFooterView. Force turn a LinearLayout object to LoadMoreFooterLayout the exception will be throw.

app:loadMoreFooterLayout="@layout/layout_irecyclerview_load_more_footer"

If you want to use LoadMoreFooterView I wrote. You can copy layout_irecyclerview_load_more_footer.xml I provided in the demo into your project.

yanxinmiao commented 8 years ago

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <com.aspsine.irecyclerview.IRecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/iRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" app:loadMoreEnabled="true" app:refreshEnabled="true" app:loadMoreFooterLayout="@layout/layout_irecyclerview_load_more_footer" app:refreshHeaderLayout="@layout/layout_irecyclerview_refresh_header" /> </LinearLayout>

this is MainActivity Layout xml

yanxinmiao commented 8 years ago

think you,The problem is solved.