0

I have a number of radio buttons on my menu. However, whenever onResume() is called, I found that it will reset all the radio buttons values to default. What I can do to keep it maintained to the previous status?

***Update I know the status of the buttons. However, they are reset. I wanna find way to manually reset them. However, I found that I used the code

 getMenuInflater().inflate(R.menu.menu_main, menu);

to try to get the menu and hence the MenuItem caused NullPointerException at the method onResume(). How can I get the menu and hence set the menuItems?

user6539552
  • 1,331
  • 2
  • 19
  • 39

1 Answers1

2

As soon as the user clicks on the radioButton, save its identifier/ID to your local storage. (example: sharedPreferences). And on the activity onResume(), check if there's any saved status of clicked radioButton, and set it clicked.

Links provided for your reference.

I didn't provide a code because you also didn't provide any codes.

Tenten Ponce
  • 2,436
  • 1
  • 13
  • 40
  • I have saved that and know that should be on or off. but i cannot get the MenuItem to reset it. Updated the question again for clarification – user6539552 Jan 04 '18 at 14:34
  • I don't actually get your updated question, it is reset and you want to manually reset it? Do you mean to `setCheck` the `radioButton`? – Tenten Ponce Jan 05 '18 at 04:56