Search in sources :

Example 1 with MenuVerticalAdapter

use of com.yanzhenjie.swiperecyclerview.adapter.MenuVerticalAdapter in project SwipeRecyclerView by yanzhenjie.

the class MenuVerticalActivity 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 MenuVerticalAdapter(mDataList);
    mMenuAdapter.setOnItemClickListener(onItemClickListener);
    mMenuRecyclerView.setAdapter(mMenuAdapter);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) MenuVerticalAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuVerticalAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 MenuVerticalAdapter (com.yanzhenjie.swiperecyclerview.adapter.MenuVerticalAdapter)1 ListViewDecoration (com.yanzhenjie.swiperecyclerview.view.ListViewDecoration)1