Example usage for android.view MenuItem setIcon

List of usage examples for android.view MenuItem setIcon

Introduction

In this page you can find the example usage for android.view MenuItem setIcon.

Prototype

public MenuItem setIcon(@DrawableRes int iconRes);

Source Link

Document

Change the icon associated with this item.

Usage

From source file:ufms.br.com.ufmsapp.fragment.DetalhesEventoFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.clear();//  www. ja v a 2  s.co m

    getActivity().getMenuInflater().inflate(R.menu.detalhe_evento_menu, menu);

    MenuItem item = menu.findItem(R.id.action_mark_favorite);

    EventoFavorite eventoFavorite = MyApplication.getWritableDatabase()
            .eventoFavoriteById(evento.getIdEventoServidor());

    if (eventoFavorite != null) {
        if (eventoFavorite.getEventoFavoriteStatus() == 0) {
            item.setIcon(R.mipmap.ic_favorite_border_white_24dp);
        } else if (eventoFavorite.getEventoFavoriteStatus() == 1) {
            item.setIcon(R.mipmap.ic_favorite_white_24dp);
        }
    }

}

From source file:de.enlightened.peris.MessageActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.conversation_menu, menu);

    if (ThemeSetter.getForegroundDark(this.accent)) {
        final MenuItem itemReply = menu.findItem(R.id.convo_menu_reply);
        final MenuItem itemDelete = menu.findItem(R.id.convo_menu_delete);

        itemReply.setIcon(R.drawable.ic_action_reply_dark);
        itemDelete.setIcon(R.drawable.ic_action_discard_dark);
    }/*from  w  ww  . j  av  a2  s .com*/

    return true;
}

From source file:de.grobox.liberario.activities.MapStationsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.map_stations_activity_actions, menu);
    mMenu = menu;// w  w  w.java  2s.  c  o  m

    MenuItem gpsItem = mMenu.findItem(R.id.action_use_gps);

    if (mLocProvider != null) {
        if (mGps) {
            gpsItem.setIcon(R.drawable.ic_gps_off);
        } else {
            gpsItem.setIcon(R.drawable.ic_gps);
        }
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.zapto.park.ParkActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuItem item1 = menu.add(Menu.NONE, 1, Menu.NONE, "Create Employee");
    item1.setIcon(android.R.drawable.ic_menu_myplaces);

    MenuItem item4 = menu.add(Menu.NONE, 4, Menu.NONE, "Update Log");
    item4.setIcon(android.R.drawable.ic_menu_more);

    MenuItem item3 = menu.add(Menu.NONE, 3, Menu.NONE, "View Log");
    item3.setIcon(android.R.drawable.ic_menu_gallery);

    MenuItem item2 = menu.add(Menu.NONE, 2, Menu.NONE, "Settings");
    item2.setIcon(android.R.drawable.ic_menu_manage);

    MenuItem item5 = menu.add(Menu.NONE, 5, Menu.NONE, "Send Emails");
    item5.setIcon(android.R.drawable.ic_menu_more);

    MenuItem item6 = menu.add(Menu.NONE, 6, Menu.NONE, "SMTP Settings");
    item6.setIcon(android.R.drawable.ic_menu_more);

    /*//  w w w  . j  a v a2  s. c om
    MenuItem item5 = menu.add(Menu.NONE, 5, Menu.NONE, "Get Dirs");
    item5.setIcon(android.R.drawable.ic_menu_manage);
    */
    return true;
}

From source file:de.enlightened.peris.ProfileFragment.java

@SuppressLint("NewApi")
@Override/*from w  ww . j ava2 s  .  c  o  m*/
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    inflater.inflate(R.menu.profile_menu, menu);
    if (ThemeSetter.getForegroundDark(this.application.getSession().getServer().serverColor)) {
        final MenuItem item = menu.findItem(R.id.profile_menu_message);
        item.setIcon(R.drawable.ic_action_new_email_dark);
    }
    if (this.userName == null
            || this.userName.contentEquals(this.application.getSession().getServer().serverUserName)) {
        final MenuItem msgitem = menu.findItem(R.id.profile_menu_message);
        msgitem.setVisible(false);
    }
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.jsharkey.oilcan.BrowserActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuItem gourl = menu.add(R.string.browse_gotourl);
    gourl.setIcon(R.drawable.ic_menu_goto);
    gourl.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            BrowserActivity.this.startSearch(webview.getUrl(), true, null, false);
            return true;
        }/*  ww  w .ja  v  a 2 s.co m*/
    });

    MenuItem refresh = menu.add(R.string.browse_refresh);
    refresh.setIcon(R.drawable.ic_menu_refresh);
    refresh.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            webview.reload();
            return true;
        }
    });

    MenuItem scripts = menu.add(R.string.browse_manage);
    scripts.setIcon(android.R.drawable.ic_menu_agenda);
    scripts.setIntent(new Intent(BrowserActivity.this, ScriptListActivity.class));

    MenuItem example = menu.add(R.string.browse_example);
    example.setIcon(R.drawable.ic_menu_bookmark);
    example.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final String[] examples = BrowserActivity.this.getResources().getStringArray(R.array.list_examples);
            new AlertDialog.Builder(BrowserActivity.this).setTitle(R.string.browse_example_title)
                    .setItems(examples, new OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            BrowserActivity.this.loadNewPage(examples[which]);
                        }
                    }).create().show();

            return true;
        }
    });

    return true;
}

From source file:org.medankulinar.MixListView.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int base = Menu.FIRST;

    /*define menu items*/
    MenuItem item1 = menu.add(base, base, base, getString(R.string.menu_item_3));
    MenuItem item2 = menu.add(base, base + 1, base + 1, getString(R.string.map_menu_cam_mode));
    /*assign icons to the menu items*/
    item1.setIcon(android.R.drawable.ic_menu_mapmode);
    item2.setIcon(android.R.drawable.ic_menu_camera);

    return true;//w  w w.  ja v  a2  s  . com
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamMobile.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem settingsItem = menu.add(0, SETTINGS_ID, 0, R.string.main_menu_settings);
    settingsItem.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_preferences));

    MenuItem aboutItem = menu.add(1, ABOUT_ID, 0, R.string.main_menu_about);
    aboutItem.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_info_details));

    MenuItem exitItem = menu.add(2, EXIT_ID, 0, R.string.main_menu_exit);
    exitItem.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_close_clear_cancel));

    if (TRACK_ENABLED) {
        MenuItem trackItem = menu.add(3, TRACK_ID, 0, "Tracks");
        trackItem.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_mapmode));
    }/*ww  w. java  2 s.  co  m*/

    return true;
}

From source file:ng.uavp.ch.ngusbterminal.MainActivity.java

@Override
public void onConfirmSelect(int actionID, String absolutePath, String fileName) {
    // Cancel pressed
    if (fileName == "") {
        ShowTab(selectedTab);//from  ww w  .  j  av a  2  s  . c o m
        return;
    }

    switch (actionID) {
    case ACTION_READFILE:
        if (!isExternalStorageReadable()) {
            showToast(R.string.err_sd_not_readable, Toast.LENGTH_SHORT);
            return;
        }
        try {
            File inputFile = new File(absolutePath, fileName);
            BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(inputFile));
            byte[] buffer = new byte[(int) inputFile.length()];
            inputStream.read(buffer);
            inputStream.close();
            usb.sendBytes(buffer);
        } catch (FileNotFoundException e1) {
            showToast(e1.getMessage(), Toast.LENGTH_SHORT);
        } catch (IOException e2) {
            showToast(e2.getMessage(), Toast.LENGTH_SHORT);
        }
        break;

    case ACTION_WRITEFILE: {
        if (!isExternalStorageWritable()) {
            showToast(R.string.err_sd_not_writeable, Toast.LENGTH_SHORT);
            return;
        }
        try {
            logtofile.StartWritingToFile(absolutePath, fileName);

            MenuItem item = menu.findItem(R.id.menu_writefile);
            item.setTitle(R.string.action_stop_log);
            item.setIcon(R.drawable.ic_doc_stop_save);

            String str = getString(R.string.action_start_log) + " " + fileName;
            showToast(str, Toast.LENGTH_SHORT);
        } catch (Exception e) {
            showToast(e.getMessage(), Toast.LENGTH_SHORT);
        }
        break;
    }
    }
    ShowTab(selectedTab);
}

From source file:cn.yibulz.caviewtest.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.switch_flash:
        if (mCameraView != null) {
            mCurrentFlash = (mCurrentFlash + 1) % FLASH_OPTIONS.length;
            item.setTitle(FLASH_TITLES[mCurrentFlash]);
            item.setIcon(FLASH_ICONS[mCurrentFlash]);
            mCameraView.setFlash(FLASH_OPTIONS[mCurrentFlash]);
        }//  ww w. j a v  a 2 s  .  co  m
        break;
    case R.id.switch_camera:
        if (mCameraView != null) {
            int facing = mCameraView.getFacing();
            mCameraView.setFacing(
                    facing == CameraView.FACING_FRONT ? CameraView.FACING_BACK : CameraView.FACING_FRONT);
        }
        break;
    }
    return false;
}