This library already included in JCenter & MavenCentral
compile 'com.lsqboy.common-adapter:common-adapter:0.0.1'
Let's start it
ListView mListView = (ListView) findViewById(R.id.list_view);
//common adapter 简单使用教程
mListView.setAdapter(new CommonAdapter<String>(this, getData(), android.R.layout.simple_list_item_1) {
@Override
public void convert(ViewHolder helper, String model) {
helper.setText(android.R.id.text1, model);
}
});
Get Data
private List<String> getData() {
mStringList = new ArrayList<>();
for (int i = 0; i < 50; i++) {
mStringList.add("string Item" + i);
}
return mStringList;
}
Apache 2.0