danoz73 / RecyclerViewFastScroller

A Fast Scroller for the RecyclerView world!
Other
1.13k stars 211 forks source link

viewpager viewpageradapter use crash #70

Open qssq666123 opened 7 years ago

qssq666123 commented 7 years ago

a.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v7.widget.RecyclerView$LayoutManager android.support.v7.widget.RecyclerView.getLayoutManager()' on a null object reference at xyz.danoz.recyclerviewfastscroller.calculation.progress.VerticalLinearLayoutManagerScrollProgressCalculator.calculateScrollProgress(VerticalLinearLayoutManagerScrollProgressCalculator.java:25) at xyz.danoz.recyclerviewfastscroller.AbsRecyclerViewFastScroller.onLayout(AbsRecyclerViewFastScroller.java:206) at android.view.View.layout(View.java:16653) at android.view.ViewGroup.layout(ViewGroup.java:5438) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080) at android.view.View.layout(View.java:16653) at android.view.ViewGroup.layout(ViewGroup.java:5438) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16653)

qssq666123 commented 7 years ago

recyclerView = ((SwipeMenuRecyclerView) findViewById(R.id.recyclerview)); recyclerView.addItemDecoration(new ListDividerItemDecoration(AppContext.getInstance(), R.drawable.shape_divider));//HORIZONTAL_LIST LinearLayoutManager linearLayoutManager = new LinearLayoutManager(AppContext.getInstance()); recyclerView.setLayoutManager(linearLayoutManager); adapter = new VoiceAdapter(); fastScroller = (VerticalRecyclerViewFastScroller) findViewById(R.id.fast_scroller); recyclerView.setAdapter(adapter); fastScroller.setRecyclerView(recyclerView); recyclerView.addOnScrollListener(fastScroller.getOnScrollListener()); swipeRefreshLayout = ((SwipeRefreshLayout) findViewById(R.id.swiperefresh)); swipeRefreshLayout.setProgressBackgroundColorSchemeColor(AppContext.getInstance().getResources().getColor(R.color.theme_color)); swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(AppContext.getInstance(), android.R.color.white)); recyclerView.setSwipeMenuCreator(VoiceUtils.getVoiceSwipeMenuCreator(AppContext.getInstance())); // 设置菜单Item点击监听。 recyclerView.setSwipeMenuItemClickListener(menuItemClickListener);

    swipeRefreshLayout.setOnRefreshListener(new android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            queryData();
        }
    });

    adapter.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(ViewGroup parent, View view, int position) {
            VoiceUtils.setAdapaterCurrentPosition(adapter, position);

// evPathFrom.setText(adapter.getData().get(position).getPath().getAbsolutePath()); } });

liya7907 commented 7 years ago

hi budy,did you fix this issue?