use of com.zhy.adapter.recyclerview.base.ViewHolder in project baseAdapter by hongyangAndroid.
the class RecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
initDatas();
mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
// mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
// mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
mAdapter = new CommonAdapter<String>(this, R.layout.item_list, mDatas) {
@Override
protected void convert(ViewHolder holder, String s, int position) {
holder.setText(R.id.id_item_list_title, s + " : " + holder.getAdapterPosition() + " , " + holder.getLayoutPosition());
}
};
initHeaderAndFooter();
// initEmptyView();
mLoadMoreWrapper = new LoadMoreWrapper(mHeaderAndFooterWrapper);
mLoadMoreWrapper.setLoadMoreView(R.layout.default_loading);
mLoadMoreWrapper.setOnLoadMoreListener(new LoadMoreWrapper.OnLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
mDatas.add("Add:" + i);
}
mLoadMoreWrapper.notifyDataSetChanged();
}
}, 3000);
}
});
mRecyclerView.setAdapter(mLoadMoreWrapper);
mAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
Toast.makeText(RecyclerViewActivity.this, "pos = " + position, Toast.LENGTH_SHORT).show();
mAdapter.notifyItemRemoved(position);
}
@Override
public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
return false;
}
});
}
use of com.zhy.adapter.recyclerview.base.ViewHolder in project baseAdapter by hongyangAndroid.
the class MultiItemTypeAdapter method onCreateViewHolder.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemViewDelegate itemViewDelegate = mItemViewDelegateManager.getItemViewDelegate(viewType);
int layoutId = itemViewDelegate.getItemViewLayoutId();
ViewHolder holder = ViewHolder.createViewHolder(mContext, parent, layoutId);
onViewHolderCreated(holder, holder.getConvertView());
setListener(parent, holder, viewType);
return holder;
}
Aggregations