当前位置: 首页>>代码示例>>Java>>正文


Java Toolbar.setNavigationOnClickListener方法代码示例

本文整理汇总了Java中android.widget.Toolbar.setNavigationOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setNavigationOnClickListener方法的具体用法?Java Toolbar.setNavigationOnClickListener怎么用?Java Toolbar.setNavigationOnClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Toolbar的用法示例。


在下文中一共展示了Toolbar.setNavigationOnClickListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this,
            android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
    setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}
 
开发者ID:googlesamples,项目名称:android-unsplash,代码行数:27,代码来源:DetailActivity.java

示例2: ActionBarDrawerToggle

import android.widget.Toolbar; //导入方法依赖的package包/类
/**
 * In the future, we can make this constructor public if we want to let developers customize
 * the
 * animation.
 */
ActionBarDrawerToggle(Activity activity, Toolbar toolbar, DrawerLayout drawerLayout,
                      DrawerArrowDrawable slider, @StringRes int openDrawerContentDescRes,
                      @StringRes int closeDrawerContentDescRes) {
  if (toolbar != null) {
    mActivityImpl = new ToolbarCompatDelegate(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (mDrawerIndicatorEnabled) {
          toggle();
        } else if (mToolbarNavigationClickListener != null) {
          mToolbarNavigationClickListener.onClick(v);
        }
      }
    });
  } else if (activity instanceof DelegateProvider) { // Allow the Activity to provide an impl
    mActivityImpl = ((DelegateProvider) activity).getDrawerToggleDelegate();
  } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    mActivityImpl = new JellybeanMr2Delegate(activity);
  } /*else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    mActivityImpl = new IcsDelegate(activity);
  } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    mActivityImpl = new HoneycombDelegate(activity);
  }*/ else {
    mActivityImpl = new DummyDelegate(activity);
  }

  mDrawerLayout = drawerLayout;
  mOpenDrawerContentDescRes = openDrawerContentDescRes;
  mCloseDrawerContentDescRes = closeDrawerContentDescRes;
  if (slider == null) {
    mSlider = new DrawerArrowDrawable(mActivityImpl.getActionBarThemedContext());
  } else {
    mSlider = slider;
  }

  mHomeAsUpIndicator = getThemeUpIndicator();
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:44,代码来源:ActionBarDrawerToggle.java

示例3: initToolBar

import android.widget.Toolbar; //导入方法依赖的package包/类
private void initToolBar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDrawerLayout.openDrawer(mNavigationView);
        }
    });
}
 
开发者ID:bluedai180,项目名称:XiangZiShen,代码行数:11,代码来源:MainActivity.java

示例4: initToolbar

import android.widget.Toolbar; //导入方法依赖的package包/类
private void initToolbar(Category category) {
    mToolbar = (Toolbar) findViewById(R.id.toolbar_activity_quiz);
    mToolbar.setTitle(category.getName());
    mToolbar.setNavigationOnClickListener(mOnClickListener);
    if (mSavedStateIsPlaying) {
        // the toolbar should not have more elevation than the content while playing
        mToolbar.setElevation(0);
    }
}
 
开发者ID:pierrebrtr,项目名称:ToutStade,代码行数:10,代码来源:QuizActivity.java

示例5: setActionBar

import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
@RequiresApi(21)
public void setActionBar(@Nullable Toolbar toolbar) {
    super.setActionBar(toolbar);
    if (null == toolbar)
        return;
    if (null == mToolbarListener) {
        mToolbarListener = new ToolbarNavigationOnClickListener();
    }
    toolbar.setNavigationOnClickListener(mToolbarListener);
}
 
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:12,代码来源:AMActivity.java

示例6: onCreate

import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this,
            android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}
 
开发者ID:googlesamples,项目名称:android-instant-apps,代码行数:42,代码来源:DetailActivity.java


注:本文中的android.widget.Toolbar.setNavigationOnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。