Skip to content
Advertisement

Tag: android-studio

onCreateOptionsMenu not being called

onCreateOptionsMenu does not get called in a fragment. I have to manually call setHasOptionsMenu(true) in onCreatedView() but this causes the item.itemId be an empty String “” in the onOptionsItemSelected() and therefore i can’t detect which menu item was tapped. I’m currently using this in a fragment: Answer Call super.onCreateOptionsMenu(menu,inflater) after menu inflate This may more help Ref :: https://stackoverflow.com/a/15654039/11393354 try

How to make a program show a toast instead of crashing?

I am working on an app. Here’s a small fragment which converts the entered string to a fraction: This works pretty well, provided you enter the number in the correct format. However, if we mess up the format, example, inserted 2 spaces or ‘/’, the app crashes and closes. I want that if the program encounters a problem in this

Advertisement