当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem类代码示例

本文整理汇总了Java中android.view.MenuItem的典型用法代码示例。如果您正苦于以下问题:Java MenuItem类的具体用法?Java MenuItem怎么用?Java MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MenuItem类属于android.view包,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent i = new Intent(this, SettingsActivity.class);
            startActivity(i);
            return true;
        case R.id.yaacc_about:
            AboutActivity.showAbout(this);
            return true;
        case R.id.yaacc_log:
            YaaccLogActivity.showLog(this);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:18,代码来源:MultiContentPlayerActivity.java

示例2: showMenu

import android.view.MenuItem; //导入依赖的package包/类
private void showMenu(Menu menu) {
  if (currentMenu == menu) {
    // no need to re-draw
    return;
  }

  menuLayout.removeAllViews();
  final int count = menu.size();
  for (int i=0; i<count; i++) {
    final MenuItem item = menu.getItem(i);
    if (item.isVisible()) {
      final View view = getMenuItemView(item);
      menuLayout.addView(view);
    }
  }

  currentMenu = menu;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:19,代码来源:AyahToolBar.java

示例3: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_logout:
            Prefs.with(this).clear();
            startActivity(new Intent(this, LoginActivity.class));
            overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
            finish();
            return true;
        case R.id.action_settings:
            startActivity(new Intent(this, SettingsActivity.class));
            overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
            return true;
        default:
            return false;
    }
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:18,代码来源:MainActivity.java

示例4: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.users_action_filter:
            sortItem.collapseActionView();
            item.expandActionView();
            return true;
        case R.id.users_action_sort:
            filterItem.collapseActionView();
            item.expandActionView();
            return true;
        case R.id.filter_default:
            presenter.sortDefault();
            sortItem.collapseActionView();
            return true;
        case R.id.filter_name_asc:
            presenter.sortByNameAsc();
            sortItem.collapseActionView();
            return true;
        case R.id.filter_name_desc:
            presenter.sortByNameDesc();
            sortItem.collapseActionView();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:27,代码来源:UsersFragment.java

示例5: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.refresh_main:
            if (isNetworkAvailable()) {
                grabData();
            }
            break;
        case R.id.more_apps:
            moreApps();
            break;
        default:
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:mzdhr,项目名称:WarningSystemWeather-Android-App,代码行数:17,代码来源:ListFragment.java

示例6: showMenu

import android.view.MenuItem; //导入依赖的package包/类
/**
 * Shows a contextual popup menu anchored to the supplied view. Item selections are passed to
 * the presenter.
 *
 * @param anchor
 * 		the view to anchor the menu to, not null
 * @param item
 * 		the LibraryItem associated with the contextual menu, not null
 */
private void showMenu(final View anchor, final LibraryItem item) {
	checkNotNull(item, "item cannot be null.");
	checkNotNull(anchor, "overflowButton cannot be null.");

	final PopupMenu menu = new PopupMenu(getContext(), anchor);
	menu.inflate(contextualMenuResourceId);
	menu.show();

	// Propagate menu selections back to the presenter
	menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(final MenuItem menuItem) {
			for (final MenuItemSelectedListener listener : menuItemSelectedListeners) {
				listener.onContextualMenuItemSelected(RecyclerBodyView.this, item, menuItem);
			}

			return true;
		}
	});
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:30,代码来源:RecyclerBodyView.java

示例7: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case Menu.FIRST:
            if (mRefreshLayout.isEnableCheckFingerInsideAnotherDirectionView()) {
                mRefreshLayout.setEnableCheckFingerInsideAnotherDirectionView(false);
                item.setTitle(R.string.enable_check_finger_inside_horizontal_view);
            } else {
                mRefreshLayout.setEnableCheckFingerInsideAnotherDirectionView(true);
                item.setTitle(R.string.disable_check_finger_inside_horizontal_view);
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:20,代码来源:TestNestedHorizontalViewsActivity.java

示例8: onNavigationItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_lsf) {
        NavigationController.getInstance().navigateToLSF();
    } else if (id == R.id.nav_canteen) {
        NavigationController.getInstance().navigateToCanteen();
    } else if (id == R.id.nav_settings) {
        NavigationController.getInstance().navigateToSettings();
    }  else if (id == R.id.nav_test) {
        startActivity(new Intent(this, VmTestActivity.class));
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:AStA-HTWG-Konstanz,项目名称:app-android,代码行数:21,代码来源:MainActivity.java

示例9: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
    }

    switch (item.getItemId()) {
        case R.id.action_about:
            IntentUtils.openUrl(this, "https://github.com/hugeterry/CoordinatorTabLayout");
            break;
        case R.id.action_about_me:
            IntentUtils.openUrl(this, "http://hugeterry.cn/about");
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:hugeterry,项目名称:CoordinatorTabLayout,代码行数:17,代码来源:MainActivity.java

示例10: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    switch (item.getItemId()){
        case R.id.changeview:
            if (recyclerView.getVisibility() == View.VISIBLE)
            {
                recyclerView.setVisibility(View.GONE);
                layoutTest.setVisibility(View.VISIBLE);
            }
            else
            {
                recyclerView.setVisibility(View.VISIBLE);
                layoutTest.setVisibility(View.GONE);
            }
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:Emadoki,项目名称:edslider,代码行数:20,代码来源:MainActivity.java

示例11: onContextItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
	if(item.getItemId() ==  R.string.copy_on_device_multi){
		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
		Tvshow tvshow = (Tvshow) mBrowserAdapter.getItem(info.position);
		ArrayList<Uri> list = new ArrayList<>();
		Cursor cursor2 = getEpisodeForShowCursor(tvshow.getTvshowId());
		if(cursor2!=null) {
			if (cursor2.getCount() > 0) {
				cursor2.moveToFirst();
				int uriCol = cursor2.getColumnIndex(VideoStore.MediaColumns.DATA);
				do {
					Uri uri = Uri.parse(cursor2.getString(uriCol));
					if (!Utils.isLocal(uri))
						list.add(uri);
				} while (cursor2.moveToNext());
				startDownloadingVideo(list);

			}
		}
		cursor2.close();
		return  true;
	}
	else return super.onContextItemSelected(item);

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:BrowserAllTvShows.java

示例12: onNavigationItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.n_home) {
        setFragment(new Tab0Home(), getString(R.string.td_main),"");
    } else if (id == R.id.n_news) {
        setFragment(new TabBrowser(), getString(R.string.td_news),"");
    } else if (id == R.id.n_drivers) {
        setFragment(new Tab2Drivers(), getString(R.string.td_drivers),"");
    } else if (id == R.id.n_stats) {
        setFragment(new Tab3Stats(), getString(R.string.td_stats),"");
    } else if (id == R.id.n_guide) {
        setFragment(new TabBrowser(), getString(R.string.td_guide), getString(R.string.link_guide));
    } else if (id == R.id.n_rules) {
        setFragment(new TabBrowser(), getString(R.string.td_rules), getString(R.string.link_rules));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:YoungPeacock,项目名称:FantaF1,代码行数:23,代码来源:MainActivity.java

示例13: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {

        // Respond to the mToolbar's back/home button
        case android.R.id.home:
            onBackPressed();
            return true;

        case R.id.menu_place_save:
            handleSaveOrUpdatePlace();
            break;

        case R.id.menu_place_delete:
            handleDeletePlace();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:21,代码来源:PlaceActivity.java

示例14: initViewListener

import android.view.MenuItem; //导入依赖的package包/类
@Override
protected void initViewListener() {
    super.initViewListener();
    fabSpeed.setMenuListener(new SimpleMenuListenerAdapter() {

        @Override
        public boolean onMenuItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case R.id.action_new:
                    startActivityForResult(new Intent(OpportunityListActivity.this,
                            NewOpportunityActivity.class), ACTION_NEW);
                    break;
                case R.id.action_search:
                    startActivityForResult(new Intent(OpportunityListActivity.this,
                            SearchActivity.class), ACTION_SEARCH);
                    break;
            }
            return super.onMenuItemSelected(menuItem);
        }
    });
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:22,代码来源:OpportunityListActivity.java

示例15: onOptionsItemSelected

import android.view.MenuItem; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    if (itemId == R.id.scan_from_picture) {
        //先申请权限
        int checked = ContextCompat.checkSelfPermission(ScannerActivity.this
                , Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (checked == PackageManager.PERMISSION_GRANTED) {
            goPicture();
        } else {
            ActivityCompat.requestPermissions(ScannerActivity.this
                    , new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE_WRITE_EXTERNAL_STORAGE);
        }
    }
    return true;
}
 
开发者ID:MRYangY,项目名称:YZxing,代码行数:17,代码来源:ScannerActivity.java


注:本文中的android.view.MenuItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。