use of android.support.v7.app.ActionBar 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 android.support.v7.app.ActionBar 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 android.support.v7.app.ActionBar 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);
}
use of android.support.v7.app.ActionBar in project SwipeRecyclerView by yanzhenjie.
the class MenuViewTypeActivity 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;
// 这里只是模拟数据,模拟Item的ViewType,根据ViewType决定显示什么菜单,到时候你可以根据你的数据来决定ViewType。
mViewTypeBeanList = new ArrayList<>();
for (int i = 0, j = 0; i < 30; i++, j++) {
ViewTypeBean viewTypeBean = new ViewTypeBean();
if (j == 0) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_NONE);
viewTypeBean.setContent("我没有菜单");
} else if (j == 1) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_SINGLE);
viewTypeBean.setContent("我有1个菜单");
} else if (j == 2) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_MULTI);
viewTypeBean.setContent("我有2个菜单");
} else if (j == 3) {
viewTypeBean.setViewType(MenuViewTypeAdapter.VIEW_TYPE_MENU_LEFT);
viewTypeBean.setContent("我的左边有菜单,右边没有");
j = -1;
}
mViewTypeBeanList.add(viewTypeBean);
}
SwipeMenuRecyclerView menuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
menuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
menuRecyclerView.addItemDecoration(new ListViewDecoration());
menuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
menuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);
MenuViewTypeAdapter menuAdapter = new MenuViewTypeAdapter(mViewTypeBeanList);
menuAdapter.setOnItemClickListener(onItemClickListener);
menuRecyclerView.setAdapter(menuAdapter);
}
use of android.support.v7.app.ActionBar in project CloudReader by youlookwhat.
the class MainActivity method initContentFragment.
private void initContentFragment() {
ArrayList<Fragment> mFragmentList = new ArrayList<>();
mFragmentList.add(new GankFragment());
mFragmentList.add(new OneFragment());
mFragmentList.add(new BookFragment());
// 注意使用的是:getSupportFragmentManager
MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), mFragmentList);
vpContent.setAdapter(adapter);
// 设置ViewPager最大缓存的页面个数(cpu消耗少)
vpContent.setOffscreenPageLimit(2);
vpContent.addOnPageChangeListener(this);
mBinding.include.ivTitleGank.setSelected(true);
vpContent.setCurrentItem(0);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
//去除默认Title显示
actionBar.setDisplayShowTitleEnabled(false);
}
}
Aggregations