use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class DragGridMenuActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mActionBar = getSupportActionBar();
assert mActionBar != null;
mActionBar.setDisplayHomeAsUpEnabled(true);
mContext = this;
mDataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
mDataList.add("我是第" + i + "个。");
}
SwipeMenuRecyclerView menuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
menuRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
// 添加分割线。
menuRecyclerView.addItemDecoration(new ListViewDecoration());
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
menuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
menuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
mMenuAdapter = new MenuAdapter(mDataList);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
menuRecyclerView.setAdapter(mMenuAdapter);
// 开启拖拽,就这么简单一句话。
menuRecyclerView.setLongPressDragEnabled(true);
// 监听拖拽,更新UI。
menuRecyclerView.setOnItemMoveListener(onItemMoveListener);
// 拖拽和侧滑删除时,手指状态监听。
menuRecyclerView.setOnItemStateChangedListener(mOnItemStateChangedListener);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class DragListMenuActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mActionBar = getSupportActionBar();
assert mActionBar != null;
mActionBar.setDisplayHomeAsUpEnabled(true);
mContext = this;
mDataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
mDataList.add("我是第" + i + "个。");
}
SwipeMenuRecyclerView menuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
menuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
// 添加分割线。
menuRecyclerView.addItemDecoration(new ListViewDecoration());
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
menuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
menuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
mMenuAdapter = new MenuAdapter(mDataList);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
menuRecyclerView.setAdapter(mMenuAdapter);
// 开启拖拽,就这么简单一句话。
menuRecyclerView.setLongPressDragEnabled(true);
// 监听拖拽,更新UI。
menuRecyclerView.setOnItemMoveListener(onItemMoveListener);
menuRecyclerView.setOnItemStateChangedListener(mOnItemStateChangedListener);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class DragSwipeListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mActionBar = getSupportActionBar();
assert mActionBar != null;
mActionBar.setDisplayHomeAsUpEnabled(true);
mDataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
mDataList.add("我是第" + i + "个。");
}
SwipeMenuRecyclerView menuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
menuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
// 添加分割线。
menuRecyclerView.addItemDecoration(new ListViewDecoration());
mMenuAdapter = new MenuAdapter(mDataList);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
menuRecyclerView.setAdapter(mMenuAdapter);
// 开启长按拖拽。
menuRecyclerView.setLongPressDragEnabled(true);
// 开启滑动删除。
menuRecyclerView.setItemViewSwipeEnabled(true);
// 监听拖拽,更新UI。
menuRecyclerView.setOnItemMoveListener(onItemMoveListener);
menuRecyclerView.setOnItemStateChangedListener(mOnItemStateChangedListener);
}
Aggregations