Search in sources :

Example 1 with MenuCardAdapter

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);
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar) MenuCardAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuCardAdapter)

Aggregations

Rect (android.graphics.Rect)1 ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 SwipeMenuRecyclerView (com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView)1 MenuCardAdapter (com.yanzhenjie.swiperecyclerview.adapter.MenuCardAdapter)1 ArrayList (java.util.ArrayList)1