List of usage examples for android.view Menu clear
public void clear();
From source file:com.coderming.weatherwatch.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { ViewParent vp = getView().getParent(); if (vp instanceof CardView) { ((View) vp).setVisibility(View.VISIBLE); }//from w w w . j av a2s . co m // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); if (com.coderming.weatherwatch.Utility.usingLocalGraphics(getActivity())) { mIconView.setImageResource( com.coderming.weatherwatch.Utility.getArtResourceForWeatherCondition(weatherId)); } else { // Use weather art image Glide.with(this) .load(com.coderming.weatherwatch.Utility.getArtUrlForWeatherCondition(getActivity(), weatherId)) .error(com.coderming.weatherwatch.Utility.getArtResourceForWeatherCondition(weatherId)) .crossFade().into(mIconView); } // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String dateText = com.coderming.weatherwatch.Utility.getFullFriendlyDayString(getActivity(), date); mDateView.setText(dateText); // Get description from weather condition ID String description = com.coderming.weatherwatch.Utility.getStringForWeatherCondition(getActivity(), weatherId); mDescriptionView.setText(description); mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description)); // For accessibility, add a content description to the icon field. Because the ImageView // is independently focusable, it's better to have a description of the image. Using // null is appropriate when the image is purely decorative or when the image already // has text describing it in the same UI component. mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description)); // Read high temperature from cursor and update view boolean isMetric = com.coderming.weatherwatch.Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = com.coderming.weatherwatch.Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString)); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = com.coderming.weatherwatch.Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString)); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText())); mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription()); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText( com.coderming.weatherwatch.Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText())); mWindLabelView.setContentDescription(mWindView.getContentDescription()); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getString(R.string.format_pressure, pressure)); mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText())); mPressureLabelView.setContentDescription(mPressureView.getContentDescription()); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); } AppCompatActivity activity = (AppCompatActivity) getActivity(); Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar); // We need to start the enter transition after the data has loaded if (mTransitionAnimation) { activity.supportStartPostponedEnterTransition(); if (null != toolbarView) { activity.setSupportActionBar(toolbarView); activity.getSupportActionBar().setDisplayShowTitleEnabled(false); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } else { if (null != toolbarView) { Menu menu = toolbarView.getMenu(); if (null != menu) menu.clear(); toolbarView.inflateMenu(R.menu.detailfragment); finishCreatingMenu(toolbarView.getMenu()); } } }
From source file:com.mifos.mifosxdroid.online.savingaccountsummary.SavingsAccountSummaryFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear(); menu.add(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME); menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents)); super.onPrepareOptionsMenu(menu); }
From source file:org.digitalcampus.oppia.activity.CourseIndexActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.activity_course_index, menu); ArrayList<CourseMetaPage> ammp = course.getMetaPages(); int order = 104; for (CourseMetaPage mmp : ammp) { Lang titleLang = mmp/*from w w w. ja v a2s. co m*/ .getLang(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())); if (titleLang != null) { String title = titleLang.getContent(); menu.add(0, mmp.getId(), order, title).setIcon(android.R.drawable.ic_menu_info_details); order++; } } UIUtils.showUserData(menu, this, course); return true; }
From source file:com.example.snapcacheexample.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // only add the menu when the selection fragment is showing if (fragments[SELECTION].isVisible()) { if (menu.size() == 0) { settings = menu.add(R.string.settings); }/*from w w w .ja va 2 s.c o m*/ return true; } else { menu.clear(); settings = null; } return false; }
From source file:org.alfresco.mobile.android.application.fragments.help.HelpDialogFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); if (!MenuFragmentHelper.canDisplayFragmentMenu(getActivity())) { return;/*w ww . j a v a2s . c o m*/ } menu.clear(); refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh); refreshIcon.setIcon(R.drawable.ic_refresh); refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }
From source file:com.raspi.chatapp.ui.chatting.ChatListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // clear the old and inflate the new optionsMenu menu.clear(); inflater.inflate(R.menu.menu_chat_list, menu); }
From source file:com.supremainc.biostar2.alarm.AlarmListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear(); MenuInflater inflater = mContext.getMenuInflater(); if (mPermissionDataProvider.getPermission(PERMISSION_MODULE.DOOR, true) || mPermissionDataProvider.getPermission(PERMISSION_MODULE.USER, true)) { switch (mSubMode) { default:/* w w w . j a va 2 s . c om*/ case MODE_NORMAL: initActionbar(getString(R.string.alarm)); if (Setting.IS_FAKE_PUSH_DATA) { inflater.inflate(R.menu.add_delete, menu); return; } inflater.inflate(R.menu.delete, menu); break; case MODE_DELETE: initActionbar(getString(R.string.delete) + " " + getString(R.string.alarm)); inflater.inflate(R.menu.delete_confirm, menu); break; } } else { inflater.inflate(R.menu.menu, menu); } super.onPrepareOptionsMenu(menu); }
From source file:com.mifos.mifosxdroid.online.loanaccountsummary.LoanAccountSummaryFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear(); menu.add(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_LOAN_NAME); menu.add(Menu.NONE, MENU_ITEM_LOAN_TRANSACTIONS, Menu.NONE, getResources().getString(R.string.transactions)); menu.add(Menu.NONE, MENU_ITEM_REPAYMENT_SCHEDULE, Menu.NONE, getResources().getString(R.string.loan_repayment_schedule)); menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents)); menu.add(Menu.NONE, MENU_ITEM_CHARGES, Menu.NONE, getResources().getString(R.string.charges)); super.onPrepareOptionsMenu(menu); }
From source file:com.harlie.android.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (getView() != null) { if (data != null && data.moveToFirst()) { ViewParent vp = getView().getParent(); if (vp != null) { if (vp instanceof CardView) { ((View) vp).setVisibility(View.VISIBLE); }//ww w . j ava 2 s. com } // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); if (Utility.usingLocalGraphics()) { mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); } else { // Use weather art image Glide.with(this).load(Utility.getArtUrlForWeatherCondition(weatherId)) .error(Utility.getArtResourceForWeatherCondition(weatherId)).crossFade() .into(mIconView); } // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String dateText = Utility.getFullFriendlyDayString(date); mDateView.setText(dateText); // Get description from weather condition ID String description = Utility.getStringForWeatherCondition(getActivity(), weatherId); mDescriptionView.setText(description); mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description)); // For accessibility, add a content description to the icon field. Because the ImageView // is independently focusable, it's better to have a description of the image. Using // null is appropriate when the image is purely decorative or when the image already // has text describing it in the same UI component. mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description)); // Read high temperature from cursor and update view @SuppressWarnings("UnusedAssignment") boolean isMetric = Utility.isMetric(); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(high); mHighTempView.setText(highString); mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString)); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(low); mLowTempView.setText(lowString); mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString)); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText())); mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription()); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText())); mWindLabelView.setContentDescription(mWindView.getContentDescription()); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getString(R.string.format_pressure, pressure)); mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText())); mPressureLabelView.setContentDescription(mPressureView.getContentDescription()); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); } AppCompatActivity activity = (AppCompatActivity) getActivity(); Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar); // We need to start the enter transition after the data has loaded if (mTransitionAnimation && activity != null) { activity.supportStartPostponedEnterTransition(); if (null != toolbarView && null != activity.getSupportActionBar()) { activity.setSupportActionBar(toolbarView); activity.getSupportActionBar().setDisplayShowTitleEnabled(false); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } else { if (null != toolbarView) { Menu menu = toolbarView.getMenu(); if (null != menu) menu.clear(); toolbarView.inflateMenu(R.menu.detailfragment); finishCreatingMenu(toolbarView.getMenu()); } } } }
From source file:com.itime.team.itime.fragments.InboxFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); inflater.inflate(R.menu.inbox, menu); }