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"]]
Little library android to create RecyclerView Adapter with simple way and fast
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.ar-android:RecyclerAdapter:1.1'
}
To use this adapter folow this step
<?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>
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);
}
}
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
}
});
RecyclerAdapter by Ahmad Rosid is licensed under a Apache License 2.0.