Search in sources :

Example 36 with ActionBar

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);
}
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) Toolbar(android.support.v7.widget.Toolbar)

Example 37 with ActionBar

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);
}
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) Toolbar(android.support.v7.widget.Toolbar)

Example 38 with ActionBar

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);
}
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)

Example 39 with ActionBar

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);
}
Also used : ListViewDecoration(com.yanzhenjie.swiperecyclerview.view.ListViewDecoration) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) MenuViewTypeAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuViewTypeAdapter) ViewTypeBean(com.yanzhenjie.swiperecyclerview.entity.ViewTypeBean) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 40 with ActionBar

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);
    }
}
Also used : GankFragment(com.example.jingbin.cloudreader.ui.gank.GankFragment) MyFragmentPagerAdapter(com.example.jingbin.cloudreader.view.MyFragmentPagerAdapter) ArrayList(java.util.ArrayList) OneFragment(com.example.jingbin.cloudreader.ui.one.OneFragment) BookFragment(com.example.jingbin.cloudreader.ui.book.BookFragment) GankFragment(com.example.jingbin.cloudreader.ui.gank.GankFragment) BookFragment(com.example.jingbin.cloudreader.ui.book.BookFragment) Fragment(android.support.v4.app.Fragment) OneFragment(com.example.jingbin.cloudreader.ui.one.OneFragment) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)443 View (android.view.View)130 Toolbar (android.support.v7.widget.Toolbar)108 TextView (android.widget.TextView)78 AppCompatActivity (android.support.v7.app.AppCompatActivity)36 ImageView (android.widget.ImageView)34 Intent (android.content.Intent)31 RecyclerView (android.support.v7.widget.RecyclerView)29 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)23 AdapterView (android.widget.AdapterView)21 Bundle (android.os.Bundle)19 BindView (butterknife.BindView)19 ViewPager (android.support.v4.view.ViewPager)18 Fragment (android.support.v4.app.Fragment)17 ArrayList (java.util.ArrayList)16 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)15 ListView (android.widget.ListView)14 SuppressLint (android.annotation.SuppressLint)13 FragmentManager (android.app.FragmentManager)12 NavigationView (android.support.design.widget.NavigationView)12