![]() |
Options Menu with Sub Items - Android Studio Tutorial |
Options Menu with Sub Items - Android Studio Tutorial
Code Example:
https://drive.google.com/drive/folders/1XRW46Zs5ik9jwoCRTxIDlOavZz_UuBDQ
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/retusBut" android:icon="@drawable/ic_ret_star" android:title="Ret" app:showAsAction="ifRoom"/> <item android:id="@+id/ShareBut" android:icon="@drawable/ic_more" android:title="Share App" app:showAsAction="never"/> </menu> //////////////////// @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_button,menu); return true; } @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { PACKAGE_NAME = getApplicationContext().getPackageName(); Intent browserIntentShare = new Intent(Intent.ACTION_VIEW, Uri.parse("https://winningsportsapp.blogspot.com/")); Intent browserIntentRetus = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + PACKAGE_NAME)); switch (item.getItemId()){ case R.id.retusBut: startActivity(browserIntentRetus); return true; case R.id.ShareBut: startActivity(browserIntentShare); return true; default: return super.onOptionsItemSelected(item); } } }
Post a Comment