本文整理了Java中android.view.MenuItem.isChecked()
方法的一些代码示例,展示了MenuItem.isChecked()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.isChecked()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:isChecked
暂无
代码示例来源: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: Rukey7/MvpApp
@Override
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
mDrawerLayout.closeDrawer(GravityCompat.START);
if (item.isChecked()) {
return true;
}
mItemId = item.getItemId();
return 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: stackoverflow.com
private boolean isChecked = false;
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem checkable = menu.findItem(R.id.checkable_menu);
checkable.setChecked(isChecked);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.checkable_menu:
isChecked = !item.isChecked();
item.setChecked(isChecked);
return true;
default:
return false;
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.run) {
DemoService.startMeUp(this, foreground.isChecked(),
importantish.isChecked());
finish();
return(true);
}
else if (item.getItemId()==R.id.foreground ) {
item.setChecked(!item.isChecked());
importantish.setEnabled(item.isChecked());
return(true);
}
else if (item.getItemId()==R.id.importantish) {
item.setChecked(!item.isChecked());
return(true);
}
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: cSploit/android
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.resolve_names:
resolveNames=!item.isChecked();
item.setChecked(resolveNames);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: cSploit/android
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.focused_scan:
if(item.isChecked()) {
item.setChecked(false);
mFocusedScan =false;
} else {
item.setChecked(true);
mFocusedScan =true;
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: square/assertj-android
public MenuItemAssert isChecked() {
isNotNull();
assertThat(actual.isChecked()) //
.overridingErrorMessage("Expected to be checked but was not checked.") //
.isTrue();
return this;
}
代码示例来源:origin: square/assertj-android
public MenuItemAssert isNotChecked() {
isNotNull();
assertThat(actual.isChecked()) //
.overridingErrorMessage("Expected to not be checked but was checked.") //
.isFalse();
return this;
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.present:
boolean original=item.isChecked();
item.setChecked(!original);
if (original) {
helper.disable();
}
else {
helper.enable();
}
break;
case R.id.first:
pager.setCurrentItem(0);
break;
case R.id.last:
pager.setCurrentItem(adapter.getCount() - 1);
break;
}
return(super.onOptionsItemSelected(item));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.present:
boolean original=item.isChecked();
item.setChecked(!original);
if (original) {
helper.disable();
}
else {
helper.enable();
}
break;
case R.id.first:
pager.setCurrentItem(0);
break;
case R.id.last:
pager.setCurrentItem(adapter.getCount() - 1);
break;
}
return(super.onOptionsItemSelected(item));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.fixed) {
item.setChecked(!item.isChecked());
if (item.isChecked()) {
if (pager.getCurrentItem()>2) {
pager.setCurrentItem(2);
}
pager.postDelayed(new Runnable() {
@Override
public void run() {
adapter.setPageCount(3);
adapter.notifyDataSetChanged();
}
}, 100);
}
else {
adapter.setPageCount(10);
adapter.notifyDataSetChanged();
}
return(true);
}
return(super.onOptionsItemSelected(item));
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.fixed) {
item.setChecked(!item.isChecked());
if (item.isChecked()) {
if (pager.getCurrentItem()>2) {
pager.setCurrentItem(2);
}
pager.postDelayed(new Runnable() {
@Override
public void run() {
adapter.setPageCount(3);
adapter.notifyDataSetChanged();
}
}, 100);
}
else {
adapter.setPageCount(10);
adapter.notifyDataSetChanged();
}
return(true);
}
return(super.onOptionsItemSelected(item));
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.fixed) {
item.setChecked(!item.isChecked());
if (item.isChecked()) {
adapter.setPageCount(3);
tabs.setTabMode(TabLayout.MODE_FIXED);
}
else {
adapter.setPageCount(10);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
}
adapter.notifyDataSetChanged();
if (pager.getCurrentItem()>=3) {
pager.setCurrentItem(2);
}
return(true);
}
return(super.onOptionsItemSelected(item));
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.fixed) {
item.setChecked(!item.isChecked());
if (item.isChecked()) {
adapter.setPageCount(3);
tabs.setTabMode(TabLayout.MODE_FIXED);
}
else {
adapter.setPageCount(10);
tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
}
adapter.notifyDataSetChanged();
if (pager.getCurrentItem()>=3) {
pager.setCurrentItem(2);
}
return(true);
}
return(super.onOptionsItemSelected(item));
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCheckTheMenuItem() throws Exception {
assertThat(item.isChecked()).isFalse();
item.setChecked(true);
assertThat(item.isChecked()).isTrue();
}
代码示例来源:origin: mikepenz/Android-Iconics
item.setChecked(!item.isChecked());
mIconsFragment.randomize(item.isChecked());
mRandomize = item.isChecked();
return true;
case R.id.action_shadow:
item.setChecked(!item.isChecked());
mIconsFragment.shadow(item.isChecked());
mShadow = item.isChecked();
return true;
case R.id.action_opensource:
代码示例来源:origin: commonsguy/cw-omnibus
case R.id.word_count_9:
case R.id.word_count_10:
item.setChecked(!item.isChecked());
代码示例来源:origin: ittianyu/BottomNavigationViewEx
/**
* get the current checked item position
*
* @return index of item, start from 0.
*/
public int getCurrentItem() {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mMenuView
private BottomNavigationItemView[] mButtons;
3. get menu and traverse it to get the checked one
*/
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. get menu and traverse it to get the checked one
Menu menu = getMenu();
for (int i = 0; i < mButtons.length; i++) {
if (menu.getItem(i).isChecked()) {
return i;
}
}
return 0;
}
代码示例来源:origin: seven332/EhViewer
@Override
public boolean onNavigationItemSelected(MenuItem item) {
if (item.isChecked()) {
return false;
内容来源于网络,如有侵权,请联系作者删除!