use of com.yanzhenjie.swiperecyclerview.entity.ViewTypeBean in project SwipeRecyclerView by yanzhenjie.
the class MenuViewTypeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
mContext = this;
// 这里只是模拟数据,模拟Item的ViewType,根据ViewType决定显示什么菜单,到时候你可以根据你的数据来决定ViewType。
mViewTypeBeanList = new ArrayList<>();
for (int i = 0, j = 0; i < 30; i++, j++) {
ViewTypeBean viewTypeBean = new ViewTypeBean();
if (j == 0) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_NONE);
viewTypeBean.setContent("我没有菜单");
} else if (j == 1) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_SINGLE);
viewTypeBean.setContent("我有1个菜单");
} else if (j == 2) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_MULTI);
viewTypeBean.setContent("我有2个菜单");
} else if (j == 3) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_LEFT);
viewTypeBean.setContent("我的左边有菜单,右边没有");
j = -1;
}
mViewTypeBeanList.add(viewTypeBean);
}
SwipeMenuRecyclerView menuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
menuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
menuRecyclerView.addItemDecoration(new ListViewDecoration());
menuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
menuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
MenuViewTypeAdapter menuAdapter = new MenuViewTypeAdapter(mViewTypeBeanList);
menuAdapter.setOnItemClickListener(onItemClickListener);
menuRecyclerView.setAdapter(menuAdapter);
}
Aggregations