cymcsg / UltimateRecyclerView

A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
Apache License 2.0
7.22k stars 1.43k forks source link

Why doesn't my swipe refresh circle show? #319

Closed ysy950803 closed 8 years ago

ysy950803 commented 8 years ago

I use UltimateRecyclerView in my fragment.xml with tablayout and there is toolbar above. As demo do, I use urv.setDefaultRefreshListener and override onRefresh, that all look like OK. But when I run my app, I pull down the list not seeing refresh circle. How to fix it?

ysy950803 commented 8 years ago

My tablayout and ViewPager are in the activity.xml, then "new" two fragments into two tabs with two xml files for fragments. My UltimateRecyclerView is in the second fragment.

ysy950803 commented 8 years ago
...extends Fragment {
    View view;
    private List<String> mDatas;
    UltimateRecyclerView ultimateRecyclerView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        mDatas = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
             mDatas.add("item_" + i);
        }

        view = inflater.inflate(R.layout.fragment_list, container, false);

        ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view);
        RVA rva = new RVA(mDatas); // RVA is my own new adapter class at the other java file.  
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        ultimateRecyclerView.setLayoutManager(linearLayoutManager);
        ultimateRecyclerView.setAdapter(rva);
        ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ultimateRecyclerView.setRefreshing(false);
                    }
                }, 3000);
            }
        });

        return view;
    }

}

But when I pull down the list, it seems not to listen my movement touch.

ysy950803 commented 8 years ago
<FrameLayout
    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="com.XXX.MainActivity">

    <com.marshalchen.ultimaterecyclerview.UltimateRecyclerView
        android:id="@+id/ultimate_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:recyclerviewClipToPadding="true"
        app:recyclerviewScrollbars="vertical">
    </com.marshalchen.ultimaterecyclerview.UltimateRecyclerView>
</FrameLayout>
jjhesk commented 8 years ago

i think your circle didnt show because the circle was not low enough

ysy950803 commented 8 years ago

@jjhesk No no, I test many times and I change the recyclerview's height to very low, but cannot see it. I make ultimaterv inside android.support.v4.widget.SwipeRefreshLayout that can show.

ysy950803 commented 8 years ago

compileSdkVersion 23 buildToolsVersion '23.0.2' minSdkVersion 15 targetSdkVersion 23

ysy950803 commented 8 years ago

Wow, now I can see the circle. I find that before it's no problem I must set a complete adapter including some list datas, better to set item layout for the list, and finally the refresh circle shows.