本文整理了Java中android.view.MenuItem.setChecked()
方法的一些代码示例,展示了MenuItem.setChecked()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setChecked()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:setChecked
暂无
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public void onPrepareOptionsMenu(Menu menu) {
MenuItem pauseOnScrollItem = menu.findItem(R.id.item_pause_on_scroll);
pauseOnScrollItem.setVisible(true);
pauseOnScrollItem.setChecked(pauseOnScroll);
MenuItem pauseOnFlingItem = menu.findItem(R.id.item_pause_on_fling);
pauseOnFlingItem.setVisible(true);
pauseOnFlingItem.setChecked(pauseOnFling);
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void restoreFilterChecked(Menu menu, int itemId) {
if (itemId != -1) {
MenuItem item = menu.findItem(itemId);
if (item == null) return;
item.setChecked(true);
}
}
代码示例来源:origin: chrisbanes/cheesesquare
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
return true;
}
});
代码示例来源:origin: TeamNewPipe/NewPipe
private void changeContentFilter(MenuItem item, List<String> contentFilter) {
this.filterItemCheckedId = item.getItemId();
item.setChecked(true);
this.contentFilter = new String[] {contentFilter.get(0)};
if (!TextUtils.isEmpty(searchString)) {
search(searchString, this.contentFilter, sortFilter);
}
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* 切换Fragment的下标
*/
private void changeFragmentIndex(MenuItem item, int currentIndex) {
index = currentIndex;
switchFragment();
item.setChecked(true);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item_pause_on_scroll:
pauseOnScroll = !pauseOnScroll;
item.setChecked(pauseOnScroll);
applyScrollListener();
return true;
case R.id.item_pause_on_fling:
pauseOnFling = !pauseOnFling;
item.setChecked(pauseOnFling);
applyScrollListener();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actions, menu);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
menu.findItem(R.id.open).setEnabled(true);
}
MenuItem checkable=menu.findItem(WORD_COUNT_MENU_IDS[wordCount-4]);
if (checkable!=null) {
checkable.setChecked(true);
}
super.onCreateOptionsMenu(menu, inflater);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actions, menu);
menu.findItem(R.id.follow).setChecked(autoFollow);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
ShoutingEchoService.STATUS.observe(this,
status -> {
if (server!=null && status!=null) server.setChecked(status.isRunning);
});
}
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_library).setChecked(true);
Fragment fragment = new MainFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment).commitAllowingStateLoss();
}
};
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_folders).setChecked(true);
Fragment fragment = new FoldersFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_playlists).setChecked(true);
Fragment fragment = new PlaylistFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_queue).setChecked(true);
Fragment fragment = new QueueFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.sort) {
item.setChecked(!item.isChecked());
adapter.sort(item.isChecked());
return(true);
}
return(super.onOptionsItemSelected(item));
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void changeService(MenuItem item) {
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(false);
ServiceHelper.setSelectedServiceId(this, item.getItemId());
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.follow) {
item.setChecked(!item.isChecked());
autoFollow=item.isChecked();
follow();
return true;
}
return super.onOptionsItemSelected(item);
}
代码示例来源:origin: commonsguy/cw-omnibus
private void updateMenu() {
if (isReady && server!=null) {
server.setEnabled(true);
server.setChecked(isServerRunning());
discover.setEnabled(true);
allowDiscovery.setEnabled(true);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCheckTheMenuItem() throws Exception {
assertThat(item.isChecked()).isFalse();
item.setChecked(true);
assertThat(item.isChecked()).isTrue();
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void showServices() {
serviceArrow.setImageResource(R.drawable.ic_arrow_up_white);
for(StreamingService s : NewPipe.getServices()) {
final String title = s.getServiceInfo().getName() +
(ServiceHelper.isBeta(s) ? " (beta)" : "");
drawerItems.getMenu()
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId()));
}
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
代码示例来源:origin: termux/termux-app
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
TerminalSession currentSession = getCurrentTermSession();
if (currentSession == null) return;
menu.add(Menu.NONE, CONTEXTMENU_SELECT_URL_ID, Menu.NONE, R.string.select_url);
menu.add(Menu.NONE, CONTEXTMENU_SHARE_TRANSCRIPT_ID, Menu.NONE, R.string.select_all_and_share);
menu.add(Menu.NONE, CONTEXTMENU_RESET_TERMINAL_ID, Menu.NONE, R.string.reset_terminal);
menu.add(Menu.NONE, CONTEXTMENU_KILL_PROCESS_ID, Menu.NONE, getResources().getString(R.string.kill_process, getCurrentTermSession().getPid())).setEnabled(currentSession.isRunning());
menu.add(Menu.NONE, CONTEXTMENU_STYLING_ID, Menu.NONE, R.string.style_terminal);
menu.add(Menu.NONE, CONTEXTMENU_TOGGLE_KEEP_SCREEN_ON, Menu.NONE, R.string.toggle_keep_screen_on).setCheckable(true).setChecked(mSettings.isScreenAlwaysOn());
menu.add(Menu.NONE, CONTEXTMENU_HELP_ID, Menu.NONE, R.string.help);
}
内容来源于网络,如有侵权,请联系作者删除!