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

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

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

Toolbar.setNavigationOnClickListener介绍

暂无

代码示例

代码示例来源:origin: jaydenxiao2016/AndroidFire

private void initToolbar() {
  toolbar.setTitle(getString(R.string.girl));
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      finish();
    }
  });
}

代码示例来源:origin: rey5137/material

public NavigationManager(NavigationDrawerDrawable navigationIcon, Toolbar toolbar){
  mToolbar = toolbar;
  mNavigationIcon = navigationIcon;
  mToolbar.setNavigationIcon(mNavigationVisible ? mNavigationIcon : null);
  mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onNavigationClick();
    }
  });
  mAnimationDuration = toolbar.getResources().getInteger(android.R.integer.config_shortAnimTime);
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(root, savedInstanceState);
  final Toolbar toolbar = root.findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      getActivity().finish();
    }
  });
  toolbar.setTitle("指定样式");
  View view = root.findViewById(R.id.recyclerView);
  if (view instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) view;
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
    recyclerView.setAdapter(new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2,this) {
      @Override
      protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
        holder.text(android.R.id.text1, model.name());
        holder.text(android.R.id.text2, model.name);
        holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
      }
    });
  }
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
public void initToolBar() {
  mToolbar.setNavigationIcon(R.drawable.ic_cancle);
  mToolbar.setTitle("登录");
  mToolbar.setNavigationOnClickListener(v -> finish());
}

代码示例来源:origin: nanchen2251/RxJava2Examples

@Override
protected void initView(Bundle savedInstanceState) {
  mWebPresenter = new WebPresenter(this);
  mWebToolbar.setNavigationOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      finish();
    }
  });
  mWebPresenter.subscribe();
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  final ActionBar ab = getSupportActionBar();
  ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
  ab.setDisplayHomeAsUpEnabled(true);
  ab.setTitle("歌单");
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  //collapsingToolbarLayout.setTitle("歌单");
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(root, savedInstanceState);
  final Toolbar toolbar = root.findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      getActivity().finish();
    }
  });
  mRefreshLayout = root.findViewById(refreshLayout);
  mRefreshLayout.setOnRefreshLoadMoreListener(this);
  mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
  mRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
  mViewPager = root.findViewById(R.id.viewPager);
  mTabLayout = root.findViewById(R.id.tableLayout);
  mViewPager.setAdapter(mAdapter = new SmartPagerAdapter(Item.values()));
  mTabLayout.setupWithViewPager(mViewPager, true);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@SuppressLint("SetTextI18n")
@Override
public void finishCreateView(Bundle state) {
  mToolbar.setTitle("设置与帮助");
  mToolbar.setNavigationIcon(R.drawable.ic_navigation_drawer);
  mToolbar.setNavigationOnClickListener(v -> {
    Activity activity1 = getActivity();
    if (activity1 instanceof MainActivity) {
      ((MainActivity) activity1).toggleDrawer();
    }
  });
  mVersionCode.setText("v" + getVersionCode());
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
public void initToolBar() {
  mToolbar.setTitle("离线缓存");
  setSupportActionBar(mToolbar);
  mToolbar.setNavigationIcon(R.drawable.action_button_back_pressed_light);
  mToolbar.setNavigationOnClickListener(v -> finish());
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_example_snaphelper);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      finish();
    }
  });
  //初始化列表和监听
  View view = findViewById(R.id.recyclerView);
  if (view instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) view;
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(new BaseRecyclerAdapter<Integer>(loadModels(), R.layout.item_example_snaphelper) {
      @Override
      protected void onBindViewHolder(SmartViewHolder holder, Integer model, int position) {
        holder.image(R.id.imageView, model);
      }
    });
    SnapHelper snapHelper = new PagerSnapHelper();
    snapHelper.attachToRecyclerView(recyclerView);
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_practice_feedlist);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      finish();
    }
  });
  final RefreshLayout refreshLayout = findViewById(R.id.refreshLayout);
  if (isFirstEnter) {
    isFirstEnter = false;
    refreshLayout.autoRefresh();
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

@Override
protected void setupToolbar() {
  super.setupToolbar();
  if (getToolbar() != null) {
    getToolbar().setNavigationOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        drawerLayout.openDrawer(Gravity.LEFT);
      }
    });
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void initToolbar(Toolbar toolbar) {
  if (DEBUG) Log.d(TAG, "initToolbar() called with: toolbar = [" + toolbar + "]");
  toolbar.setTitle(R.string.download_dialog_title);
  toolbar.setNavigationIcon(ThemeHelper.isLightThemeSelected(getActivity()) ? R.drawable.ic_arrow_back_black_24dp : R.drawable.ic_arrow_back_white_24dp);
  toolbar.inflateMenu(R.menu.dialog_url);
  toolbar.setNavigationOnClickListener(v -> getDialog().dismiss());
  toolbar.setOnMenuItemClickListener(item -> {
    if (item.getItemId() == R.id.okay) {
      prepareSelectedDownload();
      return true;
    }
    return false;
  });
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
  ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
  ab.setDisplayHomeAsUpEnabled(true);
  ab.setTitle("歌单");
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      getActivity().onBackPressed();
    }
  });
  //collapsingToolbarLayout.setTitle("歌单");
}

代码示例来源:origin: mxn21/FlowingDrawer

protected void setupToolbar() {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbar.setNavigationIcon(R.drawable.ic_menu_white);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      mDrawer.toggleMenu();
    }
  });
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("歌单");
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  toolbar.setSubtitle(albumDes);
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle(artistName);
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  toolbar.setSubtitle(artistDes);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
  public void finishCreateView(Bundle state) {
    mToolbar.setTitle("关注的人");
    mToolbar.setNavigationIcon(R.drawable.ic_navigation_drawer);
    mToolbar.setNavigationOnClickListener(v -> {
      Activity activity1 = getActivity();
      if (activity1 instanceof MainActivity) {
        ((MainActivity) activity1).toggleDrawer();
      }
    });
    mCustomEmptyView.setEmptyImage(R.drawable.img_tips_error_no_following_person);
    mCustomEmptyView.setEmptyText("你还没有关注的人哟");
  }
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
  public void finishCreateView(Bundle state) {
    mToolbar.setTitle("我的钱包");
    mToolbar.setNavigationIcon(R.drawable.ic_navigation_drawer);
    mToolbar.setNavigationOnClickListener(v -> {
      Activity activity1 = getActivity();
      if (activity1 instanceof MainActivity) {
        ((MainActivity) activity1).toggleDrawer();
      }
    });
    mCustomEmptyView.setEmptyImage(R.drawable.ic_movie_pay_area_limit);
    mCustomEmptyView.setEmptyText("你还没有消费记录哟");
  }
}

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_practice_profile);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      finish();
    }
  });
  //状态栏透明和间距处理
  StatusBarUtil.immersive(this);
  StatusBarUtil.setPaddingSmart(this, toolbar);
  StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile));
  StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurView));
}

相关文章

Toolbar类方法