Created
November 27, 2015 07:59
-
-
Save jessejohnson/89078844d02ee6a64578 to your computer and use it in GitHub Desktop.
A trivial Endless Scrolling RecyclerView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by odette on 10/28/15. | |
*/ | |
public class ContentFragment extends Fragment { | |
public static ContentFragment newInstance(){ | |
return fragment; | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View view = inflater.inflate(R.layout.fragment_content, container, false); | |
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); | |
recyclerView.setHasFixedSize(true); | |
final LinearLayoutManager llm = new LinearLayoutManager(getActivity()); | |
llm.setOrientation(LinearLayoutManager.VERTICAL); | |
recyclerView.setLayoutManager(llm); | |
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
if(llm.findLastCompletelyVisibleItemPosition() == dataArray.length() -1){ | |
Log.d(TAG, "At bottom of list!"); | |
//TODO load data here | |
} | |
} | |
}); | |
return view; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment