If you think the Android project filemanager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.binkery.app.filemanager.utils;
/*fromwww.java2s.com*/import android.view.Menu;
import android.view.MenuItem;
publicclass OptionMenuUtils {
/**
* Add the MenuItem , if it not exist .
*
* @param menu
* @param id
* @param title
*/publicstaticvoid add(Menu menu, int id, String title) {
MenuItem item = menu.findItem(id);
if (item == null) {
menu.add(0, id, 0, title);
}
}
publicstaticvoid add(Menu menu, int id, int title) {
MenuItem item = menu.findItem(id);
if (item == null) {
menu.add(0, id, 0, title);
}
}
/**
* Rename the MenuItem , if it exist .
*
* @param menu
* @param id
* @param title
*/publicstaticvoid rename(Menu menu, int id, String title) {
MenuItem item = menu.findItem(id);
if (item != null) {
item.setTitle(title);
}
}
publicstaticvoid rename(Menu menu, int id, int title) {
MenuItem item = menu.findItem(id);
if (item != null) {
item.setTitle(title);
}
}
/**
* Rename the MenuItem , if not exist add it to menu
*
* @param menu
* @param id
* @param title
*/publicstaticvoid renameOrAdd(Menu menu, int id, String title) {
MenuItem item = menu.findItem(id);
if (item == null) {
menu.add(0, id, 0, title);
} else {
item.setTitle(title);
}
}
publicstaticvoid renameOrAdd(Menu menu, int id, int title) {
MenuItem item = menu.findItem(id);
if (item == null) {
menu.add(0, id, 0, title);
} else {
item.setTitle(title);
}
}
publicstaticvoid delete(Menu menu, int id) {
menu.removeItem(id);
}
publicstaticvoid clear(Menu menu) {
menu.clear();
}
}