當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。