Example usage for android.view MenuInflater inflate

List of usage examples for android.view MenuInflater inflate

Introduction

In this page you can find the example usage for android.view MenuInflater inflate.

Prototype

public void inflate(@MenuRes int menuRes, Menu menu) 

Source Link

Document

Inflate a menu hierarchy from the specified XML resource.

Usage

From source file:com.example.google.touroflondon.MainActivity.java

/**
 * Create the option menu. Compiled from the common menu description
 * (common.xml). In addition, when in the phone layout, the phone.xml menu
 * description is also appended.//from  w  w w  .j ava  2  s .c  o  m
 * 
 * @param menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.common, menu);

    // Load special action items for the phone layout.
    if (!mIsTablet) {
        inflater.inflate(R.menu.phone, menu);
        if (mPoiListFragment != null && mPoiListFragment.isVisible()) {
            mPoiMenuItem = menu.findItem(R.id.menu_poi);
            mPoiMenuItem.setVisible(false); // hide by default
        }
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.royclarkson.springagram.GalleryListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = new MenuInflater(this.getActivity());
    inflater.inflate(R.menu.gallery_list_context_menu, menu);
}

From source file:com.androguide.honamicontrol.kernel.KernelFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.profiles, menu);
    MenuItem item = menu.findItem(R.id.profile_spinner);
    View spinner = item != null ? item.getActionView() : null;
    if (spinner instanceof android.widget.Spinner) {
        final SharedPreferences profilePrefs = super.getActivity().getSharedPreferences("PROFILES", 0);
        Spinner profiles = (Spinner) spinner;
        profiles.setAdapter(ArrayAdapter.createFromResource(super.getActivity(), R.array.profiles_array,
                R.layout.spinner_action_row));
        profiles.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override/*from  w  w w  .j  av a2s. c o m*/
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                final int currProfile = profilePrefs.getInt("CURR_PROFILE", 5);
                ActionBarActivity context = (ActionBarActivity) getActivity();
                switch (i) {
                case 0:
                    if (profileCounter > 0 && i != currProfile)
                        ProfileEnabler.enableProfile(new BatteryMaxProfile(), context);
                    profileCounter++;
                    break;
                case 1:
                    if (profileCounter > 0 && i != currProfile)
                        ProfileEnabler.enableProfile(new BatteryProfile(), context);
                    profileCounter++;
                    break;
                case 2:
                    if (profileCounter > 0 && i != currProfile)
                        ProfileEnabler.enableProfile(new BalancedProfile(), context);
                    profileCounter++;
                    break;
                case 3:
                    if (profileCounter > 0 && i != currProfile)
                        ProfileEnabler.enableProfile(new PerformanceProfile(), context);
                    profileCounter++;
                    break;
                case 4:
                    if (profileCounter > 0 && i != currProfile)
                        ProfileEnabler.enableProfile(new BenchmarkProfile(), context);
                    profileCounter++;
                    break;
                }
                profilePrefs.edit().putInt("CURR_PROFILE", i).commit();
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });

        profiles.setSelection(profilePrefs.getInt("CURR_PROFILE", 5));
    }
}

From source file:markson.visuals.sitapp.CCActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.layout.ccmenu, menu);
    Log.e("n", " CC Menu Created");
    return true;//from  ww w .java  2  s.  com
}

From source file:com.sakisds.icymonitor.fragments.history.HistoryPickerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_historypicker, menu);
}

From source file:com.example.android.touroflondon.MainActivity.java

/**
 * Create the option menu. Compiled from the common menu description (common.xml).
 * In addition, when in the phone layout, the phone.xml menu description is also appended.
 *
 * @param menu/*from  w  ww.  j  a  v  a  2  s.com*/
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.common, menu);

    // Load special action items for the phone layout.
    if (!mIsTablet) {
        inflater.inflate(R.menu.phone, menu);
        if (mPoiListFragment != null && mPoiListFragment.isVisible()) {
            mPoiMenuItem = menu.findItem(R.id.menu_poi);
            mPoiMenuItem.setVisible(false); //hide by default
        }
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.sakisds.icymonitor.fragments.ProcessesFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_processes, menu);
}

From source file:ca.farrelltonsolar.classic.DayLogChart.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.day_log_chart_menu, menu); // inflate the menu
    MenuItem shareItem = menu.findItem(R.id.day_log_chart_preference);
    setupSpinner(shareItem);/*from  ww w.  j  a  v  a  2s .c o  m*/
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:edu.nd.darts.cimon.NDroidAdmin.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    try {/*w w  w  .  j a v  a2s. c o m*/
        inflater.inflate(R.menu.options_menu, menu);
    } catch (InflateException e) {
        e.printStackTrace();
        return false;
    }
    MenuItem item = menu.findItem(R.id.startup);
    if (item != null) {
        SharedPreferences appPrefs = getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE);
        boolean startup = appPrefs.getBoolean(PREF_STARTUP, true);
        item.setChecked(startup);
    }
    return true;
}

From source file:com.starwood.anglerslong.LicenseAddActivity.java

/*********************************************************
 * Creates the action bar menu/*from w  w w .j a v  a 2  s .  c  o m*/
 *********************************************************/
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_log, menu);
    return super.onCreateOptionsMenu(menu);
}