It is a recycler view adapter that supports multiview holders, filters, and child view click events.
This is your model class. You only need to add @FlexAdapter.Item
to your model class. So there is no constraint on the supper class.
@FlexAdapter.Item
public class LabelItem {
//anything...
}
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/txtLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
This is ViewHolder. Make sure super class and onBind methods.
public class LabelRenderer extends ItemRenderer<LabelItem> {
//If the resource name is the same, the view is automatically assigned
private TextView txtLabel;
public LabelRenderer(View view) {
super(view);
}
@Override
protected void onBind(final LabelItem item) {
txtLabel.setText(item.getLabel());
}
}
//rendererFactory
RendererFactory rendererFactory = new RendererFactory();
rendererFactory.put(LabelRenderer.class, R.layout.renderer_label);
//adapter
FlexAdapter flexAdapter = new FlexAdapter(rendererFactory);
//recyclerView
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(flexAdapter);
//add items
for (int index = 0; index < 20; index++) {
flexAdapter.addItem(new LabelItem(String.valueOf(index)));
}
repositories {
jcenter()
}
dependencies {
compile 'com.scglab.common:list-adapter:1.1.1'
}
version | compileSdkVersion | minSdkVersion | date |
---|---|---|---|
1.1.1 | 23 | 15 | 25 Sep 2017 |
1.1.0 | 23 | 15 | 22 Sep 2017 |
1.0.8-beta | 23 | - | 07 Sep 2017 |
1.0.7-beta | 23 | - | 08 Sep 2017 |
repositories {
jcenter()
}
dependencies {
compile 'com.scglab.common:util:1.0.8-beta'
}
version | compileSdkVersion | minSdkVersion | date |
---|---|---|---|
1.0.8-beta | 23 | - | 07 Sep 2017 |
1.0.7-beta | 23 | - | 08 Sep 2017 |
repositories {
jcenter()
}
dependencies {
compile 'com.scglab.common:util:1.0.8-beta'
}
version | compileSdkVersion | minSdkVersion | date |
---|---|---|---|
1.0.8-beta | 23 | - | 07 Sep 2017 |
1.0.7-beta | 23 | - | 08 Sep 2017 |