本文整理汇总了Java中android.view.MenuItem.equals方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.equals方法的具体用法?Java MenuItem.equals怎么用?Java MenuItem.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectMenu
import android.view.MenuItem; //导入方法依赖的package包/类
private void selectMenu(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_home:
currentFragment = HomeFragment.newInstance();
break;
case R.id.action_course:
currentFragment = CourseFragment.newInstance();
break;
case R.id.action_schedule:
currentFragment = ScheduleFragment.newInstance();
break;
case R.id.action_about:
currentFragment = AboutFragment.newInstance();
break;
}
if (currentItem == null || !item.equals(currentItem)) {
item.setChecked(true);
FragmentTransaction beginTransaction = getSupportFragmentManager().beginTransaction();
beginTransaction.replace(R.id.container, currentFragment);
beginTransaction.commit();
}
currentItem = item;
}
示例2: onNavigationItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if (isRunning && !item.equals(runItem)) {
dialogQuitRun(item);
return false;
}
if (!(isRunning && item.equals(runItem))) {
if (itemStack.isEmpty() || !itemStack.peek().equals(item)) {
itemStack.push(item);
}
showSearchBar();
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_profile) {
toolbar.setTitle("Profile");
launchFragment(new ProfileFragment());
} else if (id == R.id.nav_run) {
toolbar.setTitle("Run");
hideSearchBar();
launchFragment(new RunningMapFragment());
} else if (id == R.id.nav_new_challenge) {
toolbar.setTitle("Search someone");
launchFragment(new EmptySearchFragment());
searchView.setQueryHint("Search someone");
searchViewAsMenuItem.expandActionView();
} else if (id == R.id.nav_messages) {
toolbar.setTitle("Challenges");
launchFragment(new MessagesFragment());
} else if (id == R.id.nav_history) {
toolbar.setTitle("History");
launchFragment(new HistoryFragment());
} else if (id == R.id.nav_logout) {
itemStack.pop();
dialogLogout();
}
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}