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:net.reichholf.dreamdroid.fragment.MovieListFragment.java

@Override
public void createOptionsMenu(Menu menu, MenuInflater inflater) {
    checkMenuReload(menu, inflater);/*from  w  ww.  j av a2  s  . c om*/
    inflater.inflate(R.menu.locactions_and_tags, menu);
}

From source file:com.agateau.equiv.ui.MealItemDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.meal_item_detail_activity_actions, menu);
    if (mMealItemPosition == NEW_MEAL_ITEM_POSITION) {
        MenuItem removeMenuItem = menu.findItem(R.id.action_remove);
        removeMenuItem.setVisible(false);
    }/*from   ww w .ja v a2  s  .c o  m*/
    mSaveMenuItem = menu.findItem(R.id.action_save);

    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mFullListAdapter.getFilter().filter(newText);
            mFavoritesListAdapter.getFilter().filter(newText);
            return false;
        }
    });

    updateMenuItems();
    return super.onCreateOptionsMenu(menu);
}

From source file:pl.bcichecki.rms.client.android.fragments.DevicesListFragment.java

private void setUpActionModeOnListItems() {
    getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

        @Override/*from   w  ww .j a va2  s.  c  om*/
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return performAction(mode, item);
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.fragment_devices_list_context, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            if (checked) {
                for (int i = 0; i < getListView().getCheckedItemPositions().size(); i++) {
                    if (i != position) {
                        getListView().setItemChecked(i, false);
                    }
                }
            }
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }
    });
}

From source file:com.skalski.websocketsclient.ActivityMain.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.kaytat.simpleprotocolplayer.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actions, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.sakisds.icymonitor.activities.ConnectionActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_connection_list, menu);
    return true;/*from   w w w . j  a  v  a2  s. c  om*/
}

From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getSupportActionBar().setTitle(Utils.applyCustomTypeFace(getString(R.string.app_name), this));
    setContentView(R.layout.activity_main);
    mEmptyView = findViewById(R.id.emptyView);
    mGridView = (GridView) findViewById(R.id.gridView);
    mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
    mGridView.setAdapter(new SecretCodeAdapter(this, Utils.getSecretCodes(this)));
    mGridView.setEmptyView(mEmptyView);//from  w ww  .j  a v  a 2s .  c o  m
    mEmptyView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mEmptyView.setEnabled(false);
            mEmptyView.animate().alpha(0)
                    .setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
            startService(new Intent(MainActivity.this, CrawlerService.class));
        }
    });
    mGridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            String code = ((SecretCode) arg0.getItemAtPosition(arg2)).getCode();
            Toast.makeText(MainActivity.this, getString(R.string.execute_code, code), Toast.LENGTH_SHORT)
                    .show();
            try {
                sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE",
                        Uri.parse("android_secret_code://" + code)));
            } catch (java.lang.SecurityException se) {
                Toast.makeText(MainActivity.this, R.string.security_exception, Toast.LENGTH_LONG).show();
            }
        }
    });

    mGridView.setMultiChoiceModeListener(new MultiChoiceModeListener() {

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            ((SecretCodeAdapter) mGridView.getAdapter()).itemCheckedStateChanged(position, checked);
            mode.setTitle(Html.fromHtml("<b>" + mGridView.getCheckedItemCount() + "</b>"));
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_delete:
                ((SecretCodeAdapter) mGridView.getAdapter()).deleteSelection(getApplicationContext());
                mode.finish();
                return true;
            case R.id.action_select_all:
                boolean check = mGridView.getCheckedItemCount() != mGridView.getCount();
                for (int i = 0; i < mGridView.getCount(); i++) {
                    mGridView.setItemChecked(i, check);
                }
                return true;
            default:
                return false;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            if (inflater != null) {
                inflater.inflate(R.menu.cab, menu);
            }
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            ((SecretCodeAdapter) mGridView.getAdapter()).resetSelection();
            supportInvalidateOptionsMenu();
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

    });

    supportInvalidateOptionsMenu();
}

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.v(TAG, "onCreateOptionsMenu: mMeeting =" + mMeeting);

    inflater.inflate(R.menu.meeting_menu, menu);
    // Only share and show charts for finished meetings
    final MenuItem shareItem = menu.findItem(R.id.action_share_meeting);
    if (shareItem != null)
        shareItem.setVisible(mMeeting != null && mMeeting.getState() == State.FINISHED);
    final MenuItem chartItem = menu.findItem(R.id.action_charts_meeting);
    if (chartItem != null)
        chartItem.setVisible(mMeeting != null && mMeeting.getState() == State.FINISHED);
    // Delete a meeting in any state.
    final MenuItem deleteItem = menu.findItem(R.id.action_delete_meeting);
    if (deleteItem != null)
        deleteItem.setVisible(mMeeting != null);
}

From source file:com.njlabs.amrita.aid.aums.AumsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.aums, menu);
    return true;/*from  w w w  . j  ava  2s.  c o  m*/

}

From source file:amhamogus.com.daysoff.fragments.AddEventFragment.java

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