How i can get the "RecyclerView" current visible item. already try different methods of recyclerview but i can't get the solution so please help and guide me
            Asked
            
        
        
            Active
            
        
            Viewed 6,650 times
        
    1
            
            
        - 
                    what have you tried so far? – Rumit Patel Jun 25 '18 at 07:19
 
1 Answers
7
             private RecyclerView.OnScrollListener recyclerViewOnScrollListener = new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
    }
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
        int visibleItemCount = linearLayoutManager.getChildCount();
        int totalItemCount = linearLayoutManager.getItemCount();
        int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
        final int lastItem = firstVisibleItemPosition + visibleItemCount;
    }
};
Declare LinearLayoutManger globally,
private LinearLayoutManager linearLayoutManager;
Initialize RecyclerView like this,
linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
notificationListRecyclerView.setLayoutManager(linearLayoutManager);
notificationListRecyclerView.addOnScrollListener(recyclerViewOnScrollListener);
        hasan_shaikh
        
- 1,434
 - 1
 - 15
 - 38