ar-android/RecyclerAdapter


Little library android to create RecyclerView Adapter for simple and fast way

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.ar-android:RecyclerAdapter:1.1'
	}
	dependencies {
		implementation("com.github.ar-android:RecyclerAdapter:1.1")
	}
	<dependency>
	    <groupId>com.github.ar-android</groupId>
	    <artifactId>RecyclerAdapter</artifactId>
	    <version>1.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.ar-android" % "RecyclerAdapter" % "1.1"
        
        

                            
    :dependencies [[com.github.ar-android/RecyclerAdapter "1.1"]]
        
        

Readme


RecyclerAdapter

Little library android to create RecyclerView Adapter with simple way and fast

Usage

Add it in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			maven { url "https://jitpack.io" }
		}
}

In your app/build.gradle

dependencies {
     compile 'com.github.ar-android:RecyclerAdapter:1.1'
}

Implementation

To use this adapter folow this step

Step 1 : Create your item view for recyclerview

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
    <TextView
        android:id="@+id/item_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:textSize="20sp"
        android:text="Null"/>

</LinearLayout>

Step 2 : Create yout viewholder

This sample view holder

public class ItemHolder extends RecyclerView.ViewHolder{
    private TextView text;

    public ItemHolder(View itemView) {
        super(itemView);
        text = (TextView) itemView.findViewById(R.id.item_text);
    }

    public void bind(String model) {
        text.setText(model);
    }
}

Step 3 : Create and set adapter


    private void setupView() {
        data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add("Recycler position " + i + 1);
        }
        rv_view = (RecyclerView) findViewById(R.id.rv_view);
        adapter = new RecyclerAdapter<String, ItemHolder>(data, String.class, R.layout.item_holder, ItemHolder.class) {
            @Override protected void bindView(ItemHolder holder, String model, int position) {
                holder.bind(model);
            }
        };
        rv_view.setLayoutManager(new LinearLayoutManager(this));
        rv_view.setAdapter(adapter);
    }

If you want to give clicklistener :

holder.itemView.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
    	//To do click listener here
    }
});

LICENCE

RecyclerAdapter by Ahmad Rosid is licensed under a Apache License 2.0.