Challenge: Deleting Crimes - Question on preferred approach

I completed the challenge by creating a 2nd XML menu file with the delete crime item and by overriding “onOptionsItemSelected” in the CrimeFragment.java.

Would a better approach be to use the existing XML file and hiding/unhiding certain Menu items based on which fragment is currently active?

Thanks in advance!

This is only my opinion, but I do not think changing the current menu XML is the best approach.

Sharing this resource would make updating the code a chore, since if you wanted to add a menu item to the list activity, you’d have to make changes in the menu XML, then the list fragment, then the crime fragment to hide the new item!

That’s 3 files to change rather than 2.

Yep. Always make a new menu XML file for each place in your code where you want a menu. There’s no benefit to having them both in the same file.

My delete icon is not displayed in the toolbar, done everything , need some help. Now only find this GEM(FORUM), Serious help in need. :cry:

@Litesam121 can you make a new forum post and add some more info about what you’re seeing? Do you see an error messages? Can you post your code? etc.

Mm. Sure, But i thought that since this is an simple problem. Do I need an seperate forum.(actually

there were no errors).

@Iscodex has helped me. That guy is incredible. If this site has a way to give respects to him. That’d be great! way to respect that Man!

Thank you. The book is awesome, worth it.
And also, For the More Curious, don’t forget “setHasOptionsMenu(true)” in OnCreate() method of the CrimeFragment class.

1 Like

hye i have problem in Question mQestionBank = new Question {};erroe

Hey
I think You must create a class that name is the Question.This class is the POJO.

hey i have errorerroe