androidx.fragment.app.Fragment.onOptionsItemSelected()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中androidx.fragment.app.Fragment.onOptionsItemSelected()方法的一些代码示例,展示了Fragment.onOptionsItemSelected()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.onOptionsItemSelected()方法的具体详情如下:
包路径:androidx.fragment.app.Fragment
类名称:Fragment
方法名:onOptionsItemSelected

Fragment.onOptionsItemSelected介绍

暂无

代码示例

代码示例来源:origin: cSploit/android

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case android.R.id.home:
      getActivity().onBackPressed();
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

@Override
public boolean onOptionsItemSelected(MenuItem item) {
 if (item.getItemId() == R.id.main_action_crop) {
  mCropImageView.getCroppedImageAsync();
  return true;
 } else if (item.getItemId() == R.id.main_action_rotate) {
  mCropImageView.rotateImage(90);
  return true;
 } else if (item.getItemId() == R.id.main_action_flip_horizontally) {
  mCropImageView.flipImageHorizontally();
  return true;
 } else if (item.getItemId() == R.id.main_action_flip_vertically) {
  mCropImageView.flipImageVertically();
  return true;
 }
 return super.onOptionsItemSelected(item);
}

代码示例来源:origin: ankidroid/Anki-Android

return super.onOptionsItemSelected(item);

代码示例来源:origin: cSploit/android

return super.onOptionsItemSelected(item);

代码示例来源:origin: westnordost/StreetComplete

@Override public boolean onOptionsItemSelected(MenuItem item)
{
  switch (item.getItemId()) {
    case R.id.action_reset:
      new AlertDialog.Builder(getContext())
        .setMessage(R.string.pref_quests_reset)
        .setPositiveButton(android.R.string.ok, (dialog, which) -> onReset())
        .setNegativeButton(android.R.string.cancel, null)
        .show();
      return true;
    case R.id.action_deselect_all:
      onDeselectAll();
      return true;
  }
  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.reset_mac:
      resetMac();
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: cemrich/zapp

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.menu_refresh:
      onRefresh();
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: gateship-one/odyssey

/**
 * Hook called when an menu item in the options menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 */
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
  switch (item.getItemId()) {
    case R.id.action_show_recent_albums:
      mRecentAlbumsSelectedListener.onRecentAlbumsSelected();
      return true;
  }
  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: offensive-security/nethunter-app

public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.deauth_modify:
      Intent i = new Intent(getActivity(), DeAuthWhitelistActivity.class);
      startActivity(i);
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: YassinAJDI/PopularMovies

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getGroupId() == R.id.menu_sort_group) {
    viewModel.setSortMoviesBy(item.getItemId());
    item.setChecked(true);
  }
  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  // Handle presses on the action bar items
  switch (item.getItemId()) {
    case R.id.bootServicesState:
      if (prefs.getBoolean(RUN_AT_BOOT, true)) {
        SharedPreferences.Editor ed = prefs.edit();
        ed.putBoolean(RUN_AT_BOOT, false);
        ed.apply();
        nh.showMessage("Boot Services DISABLED");
      } else {
        SharedPreferences.Editor ed = prefs.edit();
        ed.putBoolean(RUN_AT_BOOT, true);
        ed.apply();
        nh.showMessage("Boot Services ENABLED");
      }
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.mitmf_menu_start_service:
      start();
      return true;
    case R.id.mitmf_menu_stop_service:
      stop();
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.start_service:
      start();
      return true;
    case R.id.stop_service:
      stop();
      return true;
    case R.id.source_button:
      Intent i = new Intent(getActivity(), EditSourceActivity.class);
      i.putExtra("path", sourcePath);
      startActivity(i);
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  // Handle presses on the action bar items
  switch (item.getItemId()) {
    case R.id.start_service:
      startMana();
      return true;
    case R.id.stop_service:
      stopMana();
      return true;
    case R.id.source_button:
      Intent i = new Intent(getActivity(), EditSourceActivity.class);
      i.putExtra("path", configFilePath);
      startActivity(i);
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: offensive-security/nethunter-app

return true;
default:
  return super.onOptionsItemSelected(item);

代码示例来源:origin: offensive-security/nethunter-app

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.start_service:
      start();
      return true;
    case R.id.stop_service:
      reset();
      return true;
    case R.id.admin:
      openDialog();
      return true;
    case R.id.chooseLanguage:
      openLanguageDialog();
      return true;
    case R.id.source_button:
      Intent i = new Intent(getActivity(), EditSourceActivity.class);
      i.putExtra("path", configFilePath);
      startActivity(i);
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: andriydruk/BonjourBrowser

@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();
  //noinspection SimplifiableIfStatement
  if (id == R.id.action_add) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_add_txt_records, null);
    final TextView keyTextView = view.findViewById(R.id.key);
    final TextView valueTextView = view.findViewById(R.id.value);
    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setMessage("Add TXT record")
        .setView(view)
        .setPositiveButton(android.R.string.ok, (dialog, id1) -> {
          mRecords.put(keyTextView.getText().toString(), valueTextView.getText().toString());
          adapter.swapTXTRecords(mRecords);
          adapter.notifyDataSetChanged();
        })
        .setNegativeButton(android.R.string.cancel, (dialog, id1) -> {
        });
    builder.create().show();
    return true;
  }
  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: offensive-security/nethunter-app

return super.onOptionsItemSelected(item);

代码示例来源:origin: offensive-security/nethunter-app

return super.onOptionsItemSelected(item);

代码示例来源:origin: jruesga/rview

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch(item.getItemId()) {
    case R.id.menu_mark_as_read:
      performMarkAsReadAccountNotifications();
      return true;
    case R.id.menu_delete_all:
      //noinspection ConstantConditions
      mDialog = new AlertDialog.Builder(getActivity())
          .setTitle(R.string.account_notifications_delete_title)
          .setMessage(R.string.account_notifications_delete_message)
          .setPositiveButton(R.string.action_yes,
              (dialog, which) -> performDeleteAccountNotifications())
          .setNegativeButton(android.R.string.cancel, null)
          .setOnDismissListener(dialogInterface -> mDialog = null)
          .create();
      mDialog.show();
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

相关文章