本文整理匯總了Java中android.view.MenuItem.setChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setChecked方法的具體用法?Java MenuItem.setChecked怎麽用?Java MenuItem.setChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setChecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateOptionsMenu
import android.view.MenuItem; //導入方法依賴的package包/類
/**
* Invoked only once during app's lifetime. For successive calls see
* {@link #onPrepareOptionsMenu(Menu)}. Both used primarily to determine checkboxes for tracking
* and detection.
*
* Because the service may not available on app boot, we default to false until the service
* boots. Once that occurs, the checkboxes are driven by the service's status.
*
* @param menu
* @return
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
MenuItem toggleAttackDetectionMenuItem = menu.findItem(R.id.toggle_attack_detection);
MenuItem toggleCellTrackingMenuItem = menu.findItem(R.id.toggle_cell_tracking);
// The service may not exist on first app boot. Choose sane defaults
if (mAimsicdService == null) {
toggleAttackDetectionMenuItem.setChecked(false);
toggleCellTrackingMenuItem.setChecked(false);
} else {
toggleAttackDetectionMenuItem.setChecked(mAimsicdService.isMonitoringCell());
toggleCellTrackingMenuItem.setChecked(mAimsicdService.isTrackingCell());
}
return true;
}
示例2: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.action_wrap_lines){
item.setChecked(!item.isChecked());
wrap = item.isChecked();
PrefUtils.set(PrefUtils.CODE_WRAP, wrap);
if(ViewerActivity.ViewerType.RepoFile.equals(mPresenter.getViewerType())){
loadCode(mPresenter.getDownloadSource(), mPresenter.getExtension());
} else if(ViewerActivity.ViewerType.DiffFile.equals(mPresenter.getViewerType())){
loadDiffFile(mPresenter.getCommitFile().getPatch());
}
return true;
} else if(item.getItemId() == R.id.action_refresh){
refresh();
return true;
}
return super.onOptionsItemSelected(item);
}
示例3: handleSortOrderMenuItem
import android.view.MenuItem; //導入方法依賴的package包/類
private boolean handleSortOrderMenuItem(@NonNull MenuItem item) {
String sortOrder = null;
switch (item.getItemId()) {
case R.id.action_sort_order_artist:
sortOrder = ArtistSortOrder.ARTIST_A_Z;
break;
case R.id.action_sort_order_artist_desc:
sortOrder = ArtistSortOrder.ARTIST_Z_A;
break;
}
if (sortOrder != null) {
item.setChecked(true);
setSaveSortOrder(sortOrder);
}
return true;
}
示例4: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
/* if (id == R.id.action_force_refresh) {
updatePoems(null);
return true;
} else */
if (id == R.id.action_mark_read) {
item.setChecked(!item.isChecked());
presenter.optionMarkRead(item.isChecked());
} else if (id == R.id.action_reset_read) {
showConfirmClearReadDialog();
} else if (id == R.id.action_notify_new) {
item.setChecked(!item.isChecked());
presenter.optionNotifyNew(item.isChecked());
trackEvent("notificationOption", item.isChecked() ? "yes" : "no", null);
} else if (id == R.id.action_long_press){
item.setChecked(!item.isChecked());
presenter.optionLongPress(item.isChecked());
} else if (id == R.id.action_stats) {
presenter.optionStats();
}
return super.onOptionsItemSelected(item);
}
示例5: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Pref pref = Pref.getInstance(this);
int id = item.getItemId();
if (id == R.id.show_hidden_files_menu) {
item.setChecked(!item.isChecked());
pref.setShowHiddenFiles(item.isChecked());
} else if (id == R.id.sort_by_name_menu) {
item.setChecked(true);
pref.setFileSortType(FileListSorter.SORT_NAME);
} else if (id == R.id.sort_by_datetime_menu) {
item.setChecked(true);
pref.setFileSortType(FileListSorter.SORT_DATE);
} else if (id == R.id.sort_by_size_menu) {
item.setChecked(true);
pref.setFileSortType(FileListSorter.SORT_SIZE);
} else if (id == R.id.sort_by_type_menu) {
item.setChecked(true);
pref.setFileSortType(FileListSorter.SORT_TYPE);
}
return super.onOptionsItemSelected(item);
}
示例6: selectNavigation
import android.view.MenuItem; //導入方法依賴的package包/類
public void selectNavigation(MenuItem menuItem) {
mSelectedAccountId = mAccounts.get(0).id();
mSelectedNavigationPosition = menuItem.getOrder();
setTitle(menuItem.getTitle());
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
}
示例7: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_slow) {
sAnimatorScale = item.isChecked() ? 1 : 5;
item.setChecked(!item.isChecked());
}
return super.onOptionsItemSelected(item);
}
示例8: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.default_options:
AlarmOptions options = new AlarmOptions();
Bundle b = new Bundle();
b.putLong(AlarmNotificationService.ALARM_ID, DbUtil.Settings.DEFAULTS_ID);
options.setArguments(b);
options.show(getFragmentManager(), "default_alarm_options");
return true;
case R.id.display_notification:
boolean new_val = !item.isChecked();
item.setChecked(new_val);
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putBoolean(AlarmNotificationService.DISPLAY_NOTIFICATION, new_val)
.commit();
AlarmNotificationService.refreshNotificationBar(this);
return true;
case R.id.delete_all:
new DeleteAllConfirmation()
.show(getFragmentManager(), "confirm_delete_all");
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例9: darkClicked
import android.view.MenuItem; //導入方法依賴的package包/類
private void darkClicked(MenuItem item)
{
theme = DARK;
item.setChecked(true);
if (Build.VERSION.SDK_INT != VERSION_M)
recreate();
}
示例10: onOptionsItemSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch (id){
// TODO replace the duplicate code with function / classes
case R.id.menu_sort_recent:
if (! item.isChecked()) {
// call the sort function
item.setChecked(true);
}
break;
case R.id.menu_sort_oldest:
if (! item.isChecked()) {
// call the sort function
item.setChecked(true);
}
break;
case R.id.menu_sort_trending:
if (! item.isChecked()) {
// call the sort function
item.setChecked(true);
}
break;
}
return super.onOptionsItemSelected(item);
}
示例11: handleSortOrderMenuItem
import android.view.MenuItem; //導入方法依賴的package包/類
private boolean handleSortOrderMenuItem(@NonNull MenuItem item) {
String sortOrder = null;
switch (item.getItemId()) {
case R.id.action_sort_order_album:
sortOrder = SongSortOrder.SONG_ALBUM;
break;
case R.id.action_sort_order_title:
sortOrder = SongSortOrder.SONG_A_Z;
break;
case R.id.action_sort_order_title_desc:
sortOrder = SongSortOrder.SONG_Z_A;
break;
case R.id.action_sort_order_artist:
sortOrder = SongSortOrder.SONG_ARTIST;
break;
case R.id.action_sort_order_year:
sortOrder = SongSortOrder.SONG_YEAR;
break;
case R.id.action_sort_order_duration:
sortOrder = SongSortOrder.SONG_DURATION;
break;
case R.id.action_sort_order_date:
sortOrder = SongSortOrder.SONG_DATE;
break;
}
if (sortOrder != null) {
item.setChecked(true);
setSaveSortOrder(sortOrder);
}
return true;
}
示例12: wrapClicked
import android.view.MenuItem; //導入方法依賴的package包/類
private void wrapClicked(MenuItem item)
{
wrap = !wrap;
item.setChecked(wrap);
if (Build.VERSION.SDK_INT != VERSION_M)
recreate();
}
示例13: onDarkClick
import android.view.MenuItem; //導入方法依賴的package包/類
private boolean onDarkClick(MenuItem item)
{
dark = !dark;
item.setChecked(dark);
if (Build.VERSION.SDK_INT != VERSION_M)
recreate();
return true;
}
示例14: setActiveTab
import android.view.MenuItem; //導入方法依賴的package包/類
@ReactProp(name = "activeTab", defaultInt = 0)
public void setActiveTab(RNBottomNavigation view, int activeTab) {
Menu menu = view.getMenu();
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
if (i == activeTab) {
menuItem.setChecked(true);
} else {
menuItem.setChecked(false);
}
}
}
開發者ID:timomeh,項目名稱:react-native-android-bottom-navigation,代碼行數:14,代碼來源:RNBottomNavigationManager.java
示例15: onPageSelected
import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public void onPageSelected(int position) {
if (prevSelection != null)
prevSelection.setChecked(false);
MenuItem thisMenu = bottomTabs.getMenu().getItem(position);
thisMenu.setChecked(true);
prevSelection = thisMenu;
}