Search in sources :

Example 1 with MenuAdapter

use of me.yokeyword.sample.demo_flow.adapter.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)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 MenuAdapter (me.yokeyword.sample.demo_flow.adapter.MenuAdapter)1 OnItemClickListener (me.yokeyword.sample.demo_flow.listener.OnItemClickListener)1