use of com.yanzhenjie.swiperecyclerview.adapter.MenuCardAdapter in project SwipeRecyclerView by yanzhenjie.
the class MenuCardActivity 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;
List<String> dataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
dataList.add("我是第" + i + "个菜单");
}
mMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mMenuRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(10, 10, 10, 10);
}
});
MenuCardAdapter menuCardAdapter = new MenuCardAdapter(dataList);
menuCardAdapter.setOnItemClickListener(onItemClickListener);
mMenuRecyclerView.setAdapter(menuCardAdapter);
}
Aggregations