本文整理了Java中android.support.v7.widget.Toolbar.setOnClickListener()
方法的一些代码示例,展示了Toolbar.setOnClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.setOnClickListener()
方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:setOnClickListener
暂无
代码示例来源:origin: xinghongfei/LookLook
private void initView() {
mNest.setAlpha(0.5f);
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
mToolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mNest.smoothScrollTo(0, 0);
}
});
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandImageAndFinish();
}
});
}
代码示例来源:origin: scwang90/SmartRefreshLayout
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: scwang90/SmartRefreshLayout
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: iMeiji/Toutiao
@Override
protected void initView(View view) {
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolBar(toolbar, true, "");
toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0));
tv_hint = view.findViewById(R.id.tv_hint);
tv_save = view.findViewById(R.id.tv_save);
tv_save.setOnClickListener(this);
viewPager = view.findViewById(R.id.viewPager);
photoView = view.findViewById(R.id.photoView);
webView = view.findViewById(R.id.webview);
scrollView = view.findViewById(R.id.scrollView);
progressBar = view.findViewById(R.id.pb_progress);
int color = SettingUtil.getInstance().getColor();
progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
progressBar.show();
swipeRefreshLayout = view.findViewById(R.id.refresh_layout);
swipeRefreshLayout.setColorSchemeColors(SettingUtil.getInstance().getColor());
swipeRefreshLayout.setOnRefreshListener(() -> {
swipeRefreshLayout.post(() -> swipeRefreshLayout.setRefreshing(true));
presenter.doLoadData(shareUrl);
});
setHasOptionsMenu(true);
}
代码示例来源:origin: iMeiji/Toutiao
toolbar = view.findViewById(R.id.toolbar);
initToolBar(toolbar, true, "");
toolbar.setOnClickListener(view1 -> {
scrollView.smoothScrollTo(0, 0);
代码示例来源:origin: iMeiji/Toutiao
@Override
protected void initView(View view) {
super.initView(view);
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolBar(toolbar, true, getString(R.string.title_comment));
toolbar.setOnClickListener(view1 -> recyclerView.smoothScrollToPosition(0));
toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());
adapter = new MultiTypeAdapter(oldItems);
Register.registerNewsCommentItem(adapter);
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
if (canLoadMore) {
canLoadMore = false;
presenter.doLoadMoreData();
}
}
});
setHasOptionsMenu(true);
}
代码示例来源:origin: iMeiji/Toutiao
@Override
protected void initView(View view) {
super.initView(view);
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolBar(toolbar, true, getString(R.string.title_wenda));
toolbar.setOnClickListener(view1 -> recyclerView.smoothScrollToPosition(0));
toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());
adapter = new MultiTypeAdapter(oldItems);
Register.registerWendaContentItem(adapter);
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
if (canLoadMore) {
canLoadMore = false;
presenter.doLoadMoreData();
}
}
});
setHasOptionsMenu(true);
}
代码示例来源:origin: xinghongfei/LookLook
private void initView() {
mToolbar.setTitleMargin(20,20,0,10);
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
mToolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mNest.smoothScrollTo(0,0);
}
});
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandImageAndFinish();
}
});
mTranslateYTextView.setText(title);
WebSettings settings = wvZhihu.getSettings();
settings.setJavaScriptEnabled(true);
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
//settings.setUseWideViewPort(true);造成文字太小
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setAppCachePath(getCacheDir().getAbsolutePath() + "/webViewCache");
settings.setAppCacheEnabled(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
wvZhihu.setWebChromeClient(new WebChromeClient());
}
代码示例来源:origin: iMeiji/Toutiao
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolBar(toolbar, true, getString(R.string.title_wenda_detail));
toolbar.setOnClickListener(view12 -> scrollView.smoothScrollTo(0, 0));
代码示例来源:origin: hidroh/materialistic
final NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scroll_view);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0));
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification_compat);
ButterKnife.bind(this);
toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
toolbar.inflateMenu(R.menu.notification);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(webNotification));
notificationPresenter = new NotificationPresenter(this, this);
refreshLayout.setColorSchemeResources(R.color.color_accent);
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
onRefresh();
}
代码示例来源:origin: GcsSloop/diycode
toolbar.setOnClickListener(this);
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
ButterKnife.bind(this);
toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
toolbar.inflateMenu(R.menu.notification);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter = new MessageListAdapter(this);
recyclerView.setAdapter(adapter);
notificationPresenter = new NotificationPresenter(this, this);
refreshLayout.setColorSchemeResources(R.color.color_accent);
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
onRefresh();
}
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
enableThemeDark = ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
drawerLayout.setDrawerShadow(R.drawable.navigation_drawer_shadow, GravityCompat.START);
drawerLayout.addDrawerListener(drawerListener);
toolbar.setNavigationOnClickListener(new NavigationOpenClickListener(drawerLayout));
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
navItemDev.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
loadMoreFooter = new LoadMoreFooter(this, recyclerView, this);
adapter = new TopicListAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new FloatingActionButtonBehaviorListener.ForRecyclerView(fabCreateTopic));
mainPresenter = new MainPresenter(this, this);
updateUserInfoViews();
imgThemeDark.setImageResource(enableThemeDark ? R.drawable.ic_wb_sunny_white_24dp : R.drawable.ic_brightness_3_white_24dp);
navTopBackground.setVisibility(enableThemeDark ? View.INVISIBLE : View.VISIBLE);
refreshLayout.setColorSchemeResources(R.color.color_accent);
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
onRefresh();
}
代码示例来源:origin: TakWolf/CNode-Material-Design
toolbar.inflateMenu(R.menu.topic);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_topic_compat);
ButterKnife.bind(this);
topicId = getIntent().getStringExtra(Navigator.TopicWithAutoCompat.EXTRA_TOPIC_ID);
toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
toolbar.inflateMenu(R.menu.topic);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
topicPresenter = new TopicPresenter(this, this);
topicHeaderPresenter = new TopicHeaderPresenter(this, this);
replyPresenter = new ReplyPresenter(this, this);
createReplyView = CreateReplyDialog.createWithAutoTheme(this, topicId, this);
webTopic.addOnScrollListener(new FloatingActionButtonBehaviorListener.ForWebView(fabReply));
webTopic.setBridgeAndLoadPage(new TopicJavascriptInterface(this, createReplyView, topicHeaderPresenter, replyPresenter));
refreshLayout.setColorSchemeResources(R.color.color_accent);
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
onRefresh();
}
代码示例来源:origin: IdeaTrackerPlus/IdeaTrackerPlus
private void setUpUI() {
//Default colors
defaultPrimaryColor = ContextCompat.getColor(this, R.color.md_blue_grey_800);
defaultSecondaryColor = ContextCompat.getColor(this, R.color.md_teal_a400);
defaultTextColor = ContextCompat.getColor(this, R.color.md_white);
// Toolbar
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mToolbar.setOnClickListener(this);
// Wire the floating button
mFab = (FloatingActionButton) findViewById(R.id.fab);
mFab.setOnClickListener(this);
mFab.setOnLongClickListener(this);
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
@NonNull
static Toolbar setupToolbar(@NonNull MainActivity mainActivity) {
Toolbar toolbar = mainActivity.findViewById(R.id.toolbar);
toolbar.setOnClickListener(new WiFiBandToggle(mainActivity));
mainActivity.setSupportActionBar(toolbar);
setActionBarOptions(mainActivity.getSupportActionBar());
return toolbar;
}
代码示例来源:origin: 0xm1nam0/RxCore
@Override
public void initView() {
if (mToolbar == null || mAppBar == null) {
throw new IllegalStateException(
"The subclass of ToolbarActivity must contain a toolbar.");
}
mToolbar.setOnClickListener(v -> onToolbarClick());
setSupportActionBar(mToolbar);
if (canBack()) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);
}
if (Build.VERSION.SDK_INT >= 21) {
mAppBar.setElevation(10.6f);
}
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
@Test
public void testSetupToolbar() {
// setup
MainActivity mainActivity = mock(MainActivity.class);
Toolbar toolbar = mock(Toolbar.class);
ActionBar actionBar = mock(ActionBar.class);
when(mainActivity.findViewById(R.id.toolbar)).thenReturn(toolbar);
when(mainActivity.getSupportActionBar()).thenReturn(actionBar);
// execute
Toolbar actual = ActivityUtils.setupToolbar(mainActivity);
// validate
assertEquals(toolbar, actual);
verify(mainActivity).findViewById(R.id.toolbar);
verify(mainActivity).getSupportActionBar();
verify(toolbar).setOnClickListener(any(WiFiBandToggle.class));
verify(mainActivity).setSupportActionBar(toolbar);
verify(actionBar).setHomeButtonEnabled(true);
verify(actionBar).setDisplayHomeAsUpEnabled(true);
}
内容来源于网络,如有侵权,请联系作者删除!