android.support.v7.widget.Toolbar.findViewById()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中android.support.v7.widget.Toolbar.findViewById()方法的一些代码示例,展示了Toolbar.findViewById()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.findViewById()方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:findViewById

Toolbar.findViewById介绍

暂无

代码示例

代码示例来源:origin: iammert/MaterialIntroView

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_toolbar);
  final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  //User toolbar to access the views
  ImageView ivSearch = (ImageView) toolbar.findViewById(R.id.ivToolbarSearch);
  mIvShare = (ImageView) toolbar.findViewById(R.id.ivToolbarShare);
  mIvAbout = (ImageView) toolbar.findViewById(R.id.ivToolbarAbout);
  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.setDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
  //show the intro view
  showIntro(ivSearch, MENU_SEARCH_ID_TAG, getString(R.string.guide_setup_profile), FocusGravity.CENTER);
}

代码示例来源:origin: Yalantis/uCrop

/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
  setStatusBarColor(mStatusBarColor);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  // Set all of the Toolbar coloring
  toolbar.setBackgroundColor(mToolbarColor);
  toolbar.setTitleTextColor(mToolbarWidgetColor);
  final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
  toolbarTitle.setTextColor(mToolbarWidgetColor);
  toolbarTitle.setText(mToolbarTitle);
  // Color buttons inside the Toolbar
  Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
  stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
  toolbar.setNavigationIcon(stateButtonDrawable);
  setSupportActionBar(toolbar);
  final ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayShowTitleEnabled(false);
  }
}

代码示例来源:origin: eneim/toro

private void setupDemoButton() {
 View buttonContainer = toolbar.findViewById(R.id.home_toolbar_button);
 if (buttonContainer == null) {
  buttonContainer = LayoutInflater.from(toolbar.getContext())
    .inflate(R.layout.widget_toolbar_button, toolbar, false);
  buttonContainer.setId(R.id.home_toolbar_button);
  ActionBar.LayoutParams params = (ActionBar.LayoutParams) buttonContainer.getLayoutParams();
  params.gravity = GravityCompat.END;
  toolbar.addView(buttonContainer, params);
 }
 buttonContainer.findViewById(R.id.button_open_demos)
   .setOnClickListener(__ -> startActivity(new Intent(this, MainActivity.class)));
}

代码示例来源:origin: yaozs/YzsBaseActivity

/**
 * 初始化toolbar可重写覆盖自定的toolbar,base中实现的是通用的toolbar
 */
public void initToolBar(View rootView) {
  toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
  if (toolbar == null) {
    return;
  }
  toolbar.setTitle("");
  tv_title = (TextView) toolbar.findViewById(R.id.toolbar_title);
  tv_rightTitle = (TextView) toolbar.findViewById(R.id.tv_toolbar_right);
  iv_rightTitle = (ImageView) toolbar.findViewById(R.id.iv_toolbar_right);
}

代码示例来源:origin: jeanboydev/Android-Architecture

/**
 * 设置Toolbar的标题
 *
 * @param toolbar
 * @param resId
 */
public static void setToolBarTitle(Toolbar toolbar, int resId) {
  if (toolbar == null) return;
  TextView titleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
  if (titleView == null) return;
  titleView.setText(resId);
}

代码示例来源:origin: jeanboydev/Android-Architecture

/**
 * 设置Toolbar的标题
 *
 * @param toolbar
 * @param title
 */
public static void setToolBarTitle(Toolbar toolbar, CharSequence title) {
  if (toolbar == null) return;
  TextView titleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
  if (titleView == null) return;
  titleView.setText(title);
}

代码示例来源:origin: LLhon/Android-Video-Editor

public void setTitle(String title) {
  TextView tv = mToolbar.findViewById(R.id.toolbar_title);
  tv.setText(title);
}

代码示例来源:origin: DoAndKeep/DevJourney

public void setTitle(String title) {
  TextView titleTV = (TextView) mToolbar.findViewById(R.id.toolbar_title);
  titleTV.setText(title);
}

代码示例来源:origin: LLhon/Android-Video-Editor

public void setMenuTitle(String menuTitle, View.OnClickListener listener) {
  TextView tv = mToolbar.findViewById(R.id.toolbar_menu_title);
  tv.setText(menuTitle);
  tv.setOnClickListener(listener);
}

代码示例来源:origin: DoAndKeep/DevJourney

public void setMenuTitle(String menuTitle, View.OnClickListener listener) {
    TextView menuTitleTV = (TextView) mToolbar.findViewById(R.id.toolbar_menu_title);
    menuTitleTV.setText(menuTitle);
    menuTitleTV.setOnClickListener(listener);
  }
}

代码示例来源:origin: NightscoutFoundation/xDrip

@Override
public Point getPoint() {
  return new ViewTarget(toolbar.findViewById(menuItemId)).getPoint();
}

代码示例来源:origin: emedinaa/android-clean-architecture

private void ui() {
  setSupportActionBar(toolbar);
  toolbar.setContentInsetsAbsolute(0, 0);
  //events
  toolbar.findViewById(R.id.iviBack).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      closeApp();
    }
  });
  imageLoaderHelper= new ImageLoaderHelper(ImageLoaderHelper.GLIDE);
}

代码示例来源:origin: WuXiaolong/WoChat

public Toolbar initToolbar(int title) {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbarTitle);
  setSupportActionBar(toolbar);
  toolbarTitle.setText(title);
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
  }
  return toolbar;
}

代码示例来源:origin: WuXiaolong/WoChat

public Toolbar initToolbar(CharSequence title) {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbarTitle);
  setSupportActionBar(toolbar);
  toolbarTitle.setText(title);
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
  }
  return toolbar;
}

代码示例来源:origin: WuXiaolong/ModularSample

public Toolbar initToolBarAsHome(String title) {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
    TextView toolbaTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbaTitle.setText(title);
  }
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
  }
  return toolbar;
}

代码示例来源:origin: GoogleChromeLabs/cronet-sample

private void setUpToolbar() {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  getSupportActionBar().setDisplayShowTitleEnabled(false);
  ((TextView) toolbar.findViewById(R.id.title)).setText(R.string.toolbar_title);
}

代码示例来源:origin: casific/murmur

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.drawer_menu_contact);
  searchView = (EditText) ((MainActivity)getActivity()).getToolbar().findViewById(R.id.searchView);
  leftText = (TextView) ((MainActivity) getActivity()).getToolbar().findViewById(R.id.leftText);
  initSortSpinner();
  sortSpinner.setVisibility(View.GONE);
  View v = inflater.inflate(R.layout.contact_fragment, container, false);
  contactListView = (ListView) v.findViewById(R.id.listView);
  setListView();
  return v;
}

代码示例来源:origin: GoogleChromeLabs/cronet-sample

private void setUpToolbar() {
  Toolbar toolbar = (Toolbar) findViewById(R.id.welcome_toolbar);
  setSupportActionBar(toolbar);
  getSupportActionBar().setDisplayShowTitleEnabled(false);
  ((TextView) toolbar.findViewById(R.id.welcome_title)).setText(R.string.welcome_activity);
}

代码示例来源:origin: casific/murmur

private void initSortSpinner(){
  if(getActivity() instanceof MainActivity) {
    sortSpinner = (Spinner) ((MainActivity) getActivity()).getToolbar().findViewById(R.id.sortSpinner);
    /*sortSpinner.setAdapter(new FeedSortSpinnerAdapter(getActivity(), sortOptions, inSearchMode));
    for(int i=0; i<sortOptions.size();i++){
      if(sortOptions.get(i)[2] == currentSort){
        sortSpinner.setSelection(i);
        break;
      }
    }*/
  }
}

代码示例来源:origin: emedinaa/android-clean-architecture

private void populate() {
  if(place!=null)
  {
    int bgColor= place!=null?(Color.parseColor(place.getHeaderColor())):(Color.WHITE);
    toolbar.setBackgroundColor(bgColor);
    ((TextView)(toolbar.findViewById(R.id.tviToolbar))).setText(place.getNick());
    tviTitle.setText(place.getTitle());
    tviDesc.setText(place.getDesc());
    imageLoaderHelper.getLoader().load(place.getPhoto(),iviPlace);
  }
}

相关文章

Toolbar类方法