What is the difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu)?

StackOverflow https://stackoverflow.com/questions/14043631

سؤال

Explain difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu).

هل كانت مفيدة؟

المحلول

onCreateOptionsMenu() is called once.
onPrepareOptionsMenu() is called every time the menu opens.


From the onCreateOptionsMenu() documentation:

This is only called once, the first time the options menu is displayed. To update the menu every time it is displayed, see onPrepareOptionsMenu(Menu).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top