Skip to content

Instantly share code, notes, and snippets.

@Mariuxtheone
Last active December 26, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mariuxtheone/7156421 to your computer and use it in GitHub Desktop.
Save Mariuxtheone/7156421 to your computer and use it in GitHub Desktop.
Hide Menu Item from ActionBar - Menu if the device doesn't support a certain feature.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.menu, menu);
//Let's say we want to remove a "Share with Bluetooth" item from our Action Bar/Menu
PackageManager pm = getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
MenuItem item = menu.findItem(R.id.bluetoothSharing);
item.setVisible(false);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment