<com.sdwfqin.widget.recyclerview.AutoPollRecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recycler" android:layout_width="match_parent" android:layout_height="match_parent"/>
BaseAutoPollAdapter是对RecyclerView.Adapter的简易封装,如果想要自己定义Adapter请注意onBindViewHolder与getItemCount实现。
BaseAutoPollAdapter
RecyclerView.Adapter
Adapter
onBindViewHolder
getItemCount
public class ListPollAdapter extends BaseAutoPollAdapter<String> { public ListPollAdapter(int layoutResId, List<String> data) { super(layoutResId, data); } @Override protected void convert(BaseViewHolder helper, String item) { helper.setText(R.id.k, item); } }
List<String> list = new ArrayList<>(); for (int i = 0; i < 5; ) { list.add(" Item: " + ++i); } ListPollAdapter adapter = new ListPollAdapter(R.layout.item_home_auto_poll, list); mAutoPollRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mAutoPollRecyclerView.setAdapter(adapter); mAutoPollRecyclerView.start();
There was an error while loading. Please reload this page.