use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class MenuDrawerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
mContext = this;
mStrings = new ArrayList<>();
for (int i = 0; i < 30; i++) {
mStrings.add("我是第" + i + "个。");
}
mMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
// 添加分割线。
mMenuRecyclerView.addItemDecoration(new ListViewDecoration());
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
mMenuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
mMenuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
mMenuAdapter = new MenuAdapter(mStrings);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
mMenuRecyclerView.setAdapter(mMenuAdapter);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class MenuHorizontalActivity 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;
mDataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
mDataList.add("我是第" + i + "个。");
}
mMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
// 添加分割线。
mMenuRecyclerView.addItemDecoration(new ListViewDecoration());
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
mMenuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
mMenuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
mMenuAdapter = new MenuAdapter(mDataList);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
mMenuRecyclerView.setAdapter(mMenuAdapter);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class DragSwipeFlagsActivity 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++) {
if (i == 0) {
mDataList.add("我不能被拖拽,也不能滑动删除。");
} else {
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.setOnItemMovementListener(onItemMovementListener);
menuRecyclerView.setOnItemStateChangedListener(mOnItemStateChangedListener);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class MenuFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
List<String> dataList = new ArrayList<>();
for (int i = 0; i < 30; i++) {
dataList.add("我是第" + i + "个。");
}
// 布局管理器。
mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
// 添加分割线。
mMenuRecyclerView.addItemDecoration(new ListViewDecoration());
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
mMenuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
mMenuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
MenuAdapter menuAdapter = new MenuAdapter(dataList);
menuAdapter.setOnItemClickListener(onItemClickListener);
mMenuRecyclerView.setAdapter(menuAdapter);
}
use of com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter in project SwipeRecyclerView by yanzhenjie.
the class RefreshLoadMoreActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_refresh_load_more);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
mContext = this;
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
mSwipeRefreshLayout.setOnRefreshListener(mOnRefreshListener);
mDataList = new ArrayList<>();
for (int i = 0; i < size; i++) {
mDataList.add("我是第" + i + "个。");
}
mSwipeMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
// 布局管理器。
mSwipeMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
// 如果Item够简单,高度是确定的,打开FixSize将提高性能。
mSwipeMenuRecyclerView.setHasFixedSize(true);
// 设置Item默认动画,加也行,不加也行。
mSwipeMenuRecyclerView.setItemAnimator(new DefaultItemAnimator());
// 添加分割线。
mSwipeMenuRecyclerView.addItemDecoration(new ListViewDecoration());
// 添加滚动监听。
mSwipeMenuRecyclerView.addOnScrollListener(mOnScrollListener);
// 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
// 设置菜单创建器。
mSwipeMenuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
// 设置菜单Item点击监听。
mSwipeMenuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
mMenuAdapter = new MenuAdapter(mDataList);
mMenuAdapter.setOnItemClickListener(onItemClickListener);
mSwipeMenuRecyclerView.setAdapter(mMenuAdapter);
}
Aggregations