Search in sources :

Example 56 with Toolbar

use of android.support.v7.widget.Toolbar 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 57 with Toolbar

use of android.support.v7.widget.Toolbar 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 58 with Toolbar

use of android.support.v7.widget.Toolbar in project SwipeRecyclerView by yanzhenjie.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            outRect.set(10, 10, 10, 15);
        }
    });
    List<String> titles = Arrays.asList(getResources().getStringArray(R.array.main_item));
    List<String> descriptions = Arrays.asList(getResources().getStringArray(R.array.main_item_des));
    MainItemAdapter mainItemAdapter = new MainItemAdapter(titles, descriptions);
    mainItemAdapter.setOnItemClickListener(this);
    recyclerView.setAdapter(mainItemAdapter);
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) MainItemAdapter(com.yanzhenjie.swiperecyclerview.adapter.MainItemAdapter) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Toolbar(android.support.v7.widget.Toolbar)

Example 59 with Toolbar

use of android.support.v7.widget.Toolbar in project SwipeRecyclerView by yanzhenjie.

the class DragSwipeFlagsActivity 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++) {
        if (i == 0) {
            mDataList.add("我不能被拖拽,也不能滑动删除。");
        } else {
            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.setOnItemMovementListener(onItemMovementListener);
    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 60 with Toolbar

use of android.support.v7.widget.Toolbar in project TourGuide by worker8.

the class NavDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivity = this;
    setContentView(R.layout.activity_nav_drawer);
    /* get views from xml */
    mTextView1 = (TextView) findViewById(R.id.item1);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    /* setup toolbar */
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    toolbar.setTitle("Nav Drawer Example");
    mTutorialHandler = TourGuide.init(mActivity).with(TourGuide.Technique.CLICK).setPointer(new Pointer()).setToolTip(new ToolTip().setTitle(null).setDescription("hello world")).setOverlay(new Overlay().setBackgroundColor(Color.parseColor("#66FF0000")));
    final ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open_string, R.string.drawer_close_string) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            /* We need call playOn only after the drawer is opened,
                   so that TourGuide knows the updated location of the targetted view */
            mTutorialHandler.playOn(mTextView1);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
    /* setup clean up code */
    mTextView1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mTutorialHandler.cleanUp();
            mDrawerLayout.closeDrawers();
        }
    });
    final ViewTreeObserver viewTreeObserver = mTextView1.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            // make sure this only run once
            mTextView1.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            mDrawerLayout.openDrawer(Gravity.LEFT);
        }
    });
}
Also used : ToolTip(tourguide.tourguide.ToolTip) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Pointer(tourguide.tourguide.Pointer) Overlay(tourguide.tourguide.Overlay) TextView(android.widget.TextView) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)496 View (android.view.View)358 ActionBar (android.support.v7.app.ActionBar)178 TextView (android.widget.TextView)167 RecyclerView (android.support.v7.widget.RecyclerView)134 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)123 ImageView (android.widget.ImageView)84 Intent (android.content.Intent)75 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)56 ArrayList (java.util.ArrayList)56 BindView (butterknife.BindView)46 AppCompatActivity (android.support.v7.app.AppCompatActivity)41 AdapterView (android.widget.AdapterView)41 NavigationView (android.support.design.widget.NavigationView)39 BarPainter (com.xabber.android.ui.color.BarPainter)36 MenuItem (android.view.MenuItem)35 FloatingActionButton (android.support.design.widget.FloatingActionButton)31 ViewPager (android.support.v4.view.ViewPager)31 ViewGroup (android.view.ViewGroup)31 Bundle (android.os.Bundle)29