Skip to content

Instantly share code, notes, and snippets.

View theonlyanil's full-sized avatar

Anil Sardiwal theonlyanil

View GitHub Profile
@theonlyanil
theonlyanil / RecyclerView4.java
Last active August 22, 2018 12:21
Swipe to Delete RecyclerView
// OnCreate
{
...
ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
@theonlyanil
theonlyanil / Activity.java
Last active April 14, 2018 15:12
Make first item in RecyclerView of full width
private final static int NUM_GRIDS = 2;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
// set the layout manager.
GridLayoutManager layoutManager;
layoutManager = new GridLayoutManager(this, NUM_GRIDS);
@theonlyanil
theonlyanil / Activity.java
Created February 24, 2018 12:48
Endless Scrolling RecyclerView — Easiest Approach
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
...
// Load more - Endless Scrolling
if(position == this.getItemCount() - 1)
{
// Add a progress bar.
ProgressBar progressBar = new ProgressBar(context);
@theonlyanil
theonlyanil / MainActivity.java
Last active September 18, 2019 12:45
How to implement Item Click on RecyclerView (Easiest Approach)
/* Changes start from here... */
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
// each data item is just a string in this case
public TextView mTextView;
public ViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
mTextView = itemView.findViewById(R.id.textView);
}