[Solved] android null pointer exception [duplicate]


Try this.Assuming the variable albumList is global. and albumList is not null;

final int speedScroll = 1000;
        final Handler handler = new Handler();
        final Runnable runnable = new Runnable() {
            int count = 0;
            @Override
            public void run() {
                if(count == albumList.size())
                    count =0;
                if(count < albumList.size()){
                    recyclerView4.smoothScrollToPosition(++count);
                    handler.postDelayed(this,speedScroll);
                }
            }
        };
        handler.postDelayed(runnable,speedScroll);
    }


    @Override
    public int getItemCount() {
        return albumList.size();
    }

solved android null pointer exception [duplicate]