Search in sources :

Example 6 with MenuAdapter

use of android.support.v7.view.menu.MenuAdapter in project Fragmentation by YoKeyword.

the class MenuListFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
    mRecy.setLayoutManager(manager);
    mAdapter = new MenuAdapter(_mActivity);
    mRecy.setAdapter(mAdapter);
    mAdapter.setDatas(mMenus);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view) {
            showContent(position);
        }
    });
    if (savedInstanceState != null) {
        mCurrentPosition = savedInstanceState.getInt(SAVE_STATE_POSITION);
        mAdapter.setItemChecked(mCurrentPosition);
    } else {
        mCurrentPosition = 0;
        mAdapter.setItemChecked(0);
    }
}
Also used : OnItemClickListener(me.yokeyword.sample.demo_flow.listener.OnItemClickListener) MenuAdapter(me.yokeyword.sample.demo_flow.adapter.MenuAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 7 with MenuAdapter

use of android.support.v7.view.menu.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);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) MenuAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ActionBar(android.support.v7.app.ActionBar) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Toolbar(android.support.v7.widget.Toolbar)

Example 8 with MenuAdapter

use of android.support.v7.view.menu.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);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) MenuAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 9 with MenuAdapter

use of android.support.v7.view.menu.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);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) MenuAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Toolbar(android.support.v7.widget.Toolbar)

Example 10 with MenuAdapter

use of android.support.v7.view.menu.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);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) MenuAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)10 ListViewDecoration (com.yanzhenjie.swiperecyclerview.view.ListViewDecoration)9 Toolbar (android.support.v7.widget.Toolbar)8 MenuAdapter (com.yanzhenjie.swiperecyclerview.adapter.MenuAdapter)8 SwipeMenuRecyclerView (com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView)5 ActionBar (android.support.v7.app.ActionBar)4 View (android.view.View)3 SuppressLint (android.annotation.SuppressLint)2 MenuAdapter (android.support.v7.view.menu.MenuAdapter)2 MenuBuilder (android.support.v7.view.menu.MenuBuilder)2 ListPopupWindow (android.support.v7.widget.ListPopupWindow)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ArrayList (java.util.ArrayList)2 Activity (android.app.Activity)1 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 SearchView (android.support.v7.widget.SearchView)1 Editable (android.text.Editable)1