What does this method do super.onCreateOptionMenu() and super.onOptionsItemSelected(item)

后端 未结 4 1812
北恋
北恋 2021-01-24 09:40

I am new to android. I know this question have been asked before but, i am still confuse . What this method does when returning them inside my onCreateOptionMenu() and onOptionI

4条回答
  •  旧时难觅i
    2021-01-24 09:59

    Ok. I got you question:

    Que 1 :

    What this method does when returning them inside my onCreateOptionMenu() and onOptionItemSelected()

    Ans :

    onCreateOptionMenu() used for inflate menu in action bar.

    onOptionItemSelected() used for capture onclick of that menus

    Que 2 :

    if i return true or false

    Ans :

    ref !!! you should return true if you have inflated menu in that file or your defined menu is clicked. else u should return false. so compiler will find for men or menu item in other page.

    eg. you have one activity and two fragment, then if menu or menu item not find in activity then compiler will find it in fragment. if you return true then no further search.

    Que 3 :

    why to use super ?

    Ans :

    so compiler get to know that in this file there is no user defined menu or item value.

提交回复
热议问题