本文整理汇总了Java中android.view.MenuItem.getGroupId方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.getGroupId方法的具体用法?Java MenuItem.getGroupId怎么用?Java MenuItem.getGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.getGroupId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.media_variations_clear_cache) {
Fresco.getImagePipeline().clearCaches();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActivity().recreate();
} else {
Toast.makeText(
getActivity(),
R.string.imagepipeline_media_variations_restart_toast,
Toast.LENGTH_SHORT).show();
getActivity().finish();
}
return true;
} else if (item.getGroupId() == R.id.media_variations_modes) {
for (Mode mode : Mode.values()) {
if (mode.menuItemId == item.getItemId()) {
setMode(mode);
break;
}
}
clearMainImageAndBitmapCache();
item.setChecked(true);
}
return super.onOptionsItemSelected(item);
}
示例2: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onContextItemSelected(MenuItem item) {
if (item.getGroupId() != ConfigUtil.DOWNLOADING_MENU_GROUP_ID) {
return false;
}
int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;// 获取点击了第几行
DownloadInfo downloadInfo = (DownloadInfo) downloadAdapter.getItem(selectedPosition);
String title = downloadInfo.getTitle();
// 删除数据库记录
DataSet.removeDownloadInfo(title);
File file = new File(Environment.getExternalStorageDirectory()+"/CCDownload", title+".mp4");
if(file.exists()){
file.delete();
}
// 通知service取消下载
if (!binder.isStop() && binder.exists(title)) {
binder.cancel(title);
startWaitStatusDownload();
}
initData();
downloadAdapter.notifyDataSetChanged();
downloadingListView.invalidate();
if (getUserVisibleHint()) {
return true;
}
return false;
}
示例3: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getGroupId() != ConfigUtil.DOWNLOADED_MENU_GROUP_ID) {
return false;
}
int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;
Pair<String, Integer> pair = (Pair<String, Integer>)videoListViewAdapter.getItem(selectedPosition);
DataSet.removeDownloadInfo(pair.first);
File file = new File(Environment.getExternalStorageDirectory()+"/"+ConfigUtil.DOWNLOAD_DIR, pair.first+".mp4");
if(file.exists()){
file.delete();
}
initData();
videoListViewAdapter.notifyDataSetChanged();
downloadedListView.invalidate();
if (getUserVisibleHint()) {
return true;
}
return false;
}
示例4: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
int id_group = item.getGroupId();
switch (id_group) {
case ID_GROUP_TEACHER:
String name = item.getTitle().toString();
mView_TeacherName.setText(name);
break;
}
return super.onContextItemSelected(item);
}
示例5: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
int id_group = item.getGroupId();
switch (id_group) {
case ID_GROUP_SUBJECT:
changeSubject(item.getItemId());
break;
}
return super.onContextItemSelected(item);
}
示例6: onActionItemClicked
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
switch (menuItem.getItemId()) {
case R.id.query_cab_schedule:
displayScheduleTimestampDialog(R.id.query_cab_schedule, mSelection.getIds());
break;
case R.id.query_cab_state:
/* Add all known states to menu. */
SubMenu subMenu = menuItem.getSubMenu();
if (subMenu != null) {
subMenu.clear();
for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
}
}
break;
default:
/* Click on one of the state keywords. */
if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
if (mListener != null) {
mListener.onStateChangeRequest(mSelection.getIds(), menuItem.getTitle().toString());
}
return true;
}
return false; // Not handled.
}
return true; // Handled.
}
示例7: onActionItemClicked
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
TreeSet<Long> selectionIds;
switch (menuItem.getItemId()) {
case R.id.query_cab_schedule:
selectionIds = originalSelectedIds();
if (!selectionIds.isEmpty()) {
displayScheduleTimestampDialog(R.id.query_cab_schedule, selectionIds);
}
break;
case R.id.query_cab_state:
/* Add all known states to menu. */
SubMenu subMenu = menuItem.getSubMenu();
if (subMenu != null) {
subMenu.clear();
for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
}
}
break;
default:
/* Click on one of the state keywords. */
if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
if (mListener != null) {
selectionIds = originalSelectedIds();
if (!selectionIds.isEmpty()) {
mListener.onStateChangeRequest(selectionIds, menuItem.getTitle().toString());
}
}
return true;
}
return false; // Not handled.
}
return true; // Handled.
}
示例8: setExclusiveItemChecked
import android.view.MenuItem; //导入方法依赖的package包/类
void setExclusiveItemChecked(MenuItem item) {
int group = item.getGroupId();
int N = this.mItems.size();
for (int i = 0; i < N; i++) {
MenuItem curItem = (MenuItemImpl) this.mItems.get(i);
if (curItem.getGroupId() == group && curItem.isExclusiveCheckable() && curItem.isCheckable()) {
curItem.setCheckedInt(curItem == item);
}
}
}
示例9: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getGroupId()) {
case R.id.delete:
deleteItem(item.getItemId());
return true;
case R.id.edit:
Intent i = new Intent(MainActivity.this, AddTestActivity.class);
i.putExtra(AddTestActivity.ARG_TEST_ID, socTests.get(item.getItemId()).getId());
startActivity(i);
return true;
default:
return super.onContextItemSelected(item);
}
}
示例10: onNavigationItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int loaderId = 0;
switch(item.getGroupId()){
case R.id.navgroup_list:
switch(item.getItemId()){
case R.id.nav_incomplete:
loaderId = 1;
break;
case R.id.nav_expired:
loaderId = 2;
break;
case R.id.nav_completed:
loaderId = 3;
break;
case R.id.nav_archive:
loaderId = 4;
break;
case R.id.nav_deleted:
loaderId = 5;
break;
}
navigationView.setCheckedItem(item.getItemId());
ToduleListFragment frag = ToduleListFragment.newInstance(loaderId);
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.fragment_container, frag, "list_frag" + String.valueOf(loaderId))
.commit();
mDrawerLayout.closeDrawer(GravityCompat.START);
return true;
case R.id.navgroup_setting:
switch(item.getItemId()){
case R.id.nav_label:
navigationView.setCheckedItem(item.getItemId());
ToduleLabelFragment labelFrag = ToduleLabelFragment.newInstance(false, null);
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.fragment_container, labelFrag)
.commit();
mDrawerLayout.closeDrawer(GravityCompat.START);
break;
}
return true;
}
return true;
}
示例11: onOptionsItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (upIntent != null)
if (NavUtils.shouldUpRecreateTask(this, upIntent))
TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
else
NavUtils.navigateUpTo(this, upIntent);
return true;
case R.id.menu_usage:
optionUsage();
return true;
case R.id.menu_accounts:
optionAccounts();
return true;
case R.id.menu_applications:
optionApplications();
return true;
case R.id.menu_contacts:
if (item.getGroupId() != 0) {
optionContacts(item.getGroupId());
return true;
} else
return false;
case R.id.menu_whitelists:
optionWhitelists(null);
return true;
case R.id.menu_apply:
optionTemplate();
return true;
case R.id.menu_clear:
optionClear();
return true;
case R.id.menu_export:
optionExport();
return true;
case R.id.menu_import:
optionImport();
return true;
case R.id.menu_submit:
optionSubmit();
return true;
case R.id.menu_fetch:
optionFetch();
return true;
case R.id.menu_settings:
optionSettings();
return true;
case R.id.menu_dump:
optionDump();
return true;
case R.id.menu_legend:
optionLegend();
return true;
case R.id.menu_tutorial:
optionTutorial();
return true;
default:
return super.onOptionsItemSelected(item);
}
}