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:cn.edu.nju.dapenti.activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.drawer, menu);

        mEntriesFragment.setHasOptionsMenu(false);
    } else {/*ww w  .j  a  va2  s. c o  m*/
        mEntriesFragment.setHasOptionsMenu(true);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.joefernandez.irrduino.android.remote.IrrduinoRemoteActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.app_menu, menu);
    return true;//from  ww w. j a  v a  2  s  .c  o  m
}

From source file:com.purplefrog.glitchclocka.LearningReadout.java

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

From source file:com.akop.bach.fragment.xboxlive.SentMessagesFragment.java

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

    inflater.inflate(R.menu.xbl_sent_message_list, menu);
}

From source file:jen.jobs.application.UpdateJobSeeking.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.save, menu);
    return true;//w w  w  .  j  a va2 s. com
}

From source file:co.carlosandresjimenez.android.gotit.RegistrationFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.registration, menu);
}

From source file:cat.wuyingren.rorhelper.fragments.GameListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    dataSource = new GameDataSource(getActivity());
    dataSource.open();//from w w  w .  j a  v a  2  s.co  m

    values = dataSource.getAllGames();

    adapter = new MultipleRowAdapter(getActivity(), values);

    setListAdapter(adapter);

    final ListView listView = getListView();
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() {

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            // Here you can do something when items are selected/de-selected,
            // such as update the title in the CAB
            //mode.setTag();
            int selectionColor = getResources().getColor(R.color.colorPrimary);
            Log.w("TAG", "onItemCheckedStateChanged() " + checked + " " + position);
            mode.setSubtitle(listView.getCheckedItemCount() + " selected");
            if (checked) {
                listView.getChildAt(position).setBackgroundColor(selectionColor);
            } else {
                listView.getChildAt(position)
                        .setBackgroundColor(getResources().getColor(android.R.color.transparent));
            }
        }

        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
            // Inflate the menu for the CAB

            Log.w("TAG", "onCreateActionMode");
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.menu_context, menu);
            mode.setTitle(getString(R.string.action_choose));
            return true;
        }

        @Override
        public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
            // Here you can perform updates to the CAB due to
            // an invalidate() request
            return false;
        }

        @Override
        public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
            // Respond to clicks on the actions in the CAB

            switch (item.getItemId()) {
            case R.id.action_delete:
                deleteItems(listView.getCheckedItemPositions());
                mode.finish();
                return true;
            default:
                return false;
            }
        }

        @Override
        public void onDestroyActionMode(android.view.ActionMode mode) {
            // Here you can make any necessary updates to the activity when
            // the CAB is removed. By default, selected items are deselected/unchecked.

            SparseBooleanArray checked = listView.getCheckedItemPositions();
            for (int i = 0; i < listView.getAdapter().getCount(); i++) {
                if (checked.get(i)) {
                    listView.getChildAt(i)
                            .setBackgroundColor(getResources().getColor(android.R.color.transparent));
                }
            }
        }

    });
    // dataSource.close();
}

From source file:com.cianmcgovern.android.ShopAndShare.Share.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inf = getMenuInflater();
    inf.inflate(R.layout.default_menu, menu);
    return true;// w  w  w .  j a v  a 2s . c om
}

From source file:net.palacesoft.cngstation.client.StationActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.main_menu, menu);
    return true;/*w  w  w.  j  a v  a  2  s .c  o m*/
}

From source file:bbct.android.common.activity.BaseballCardDetails.java

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