Android : Get view Reference to a Menu Item

前端 未结 6 718
醉酒成梦
醉酒成梦 2020-11-27 05:19

I plan to use quick actions UI pattern in my application. Android Quick Actions UI Pattern . The quick action window needs a pivot view to stick to.

    qui         


        
6条回答
  •  感情败类
    2020-11-27 05:43

    in the main activity class, best to override the onOptionsItemSelected(...) method; should be something as below:

    public boolean onOptionsItemSelected(MenuItem item) {
      // the id is of type int
      int someId = item.getItemId();
      // can use an if() or switch() statement to check if id is selected
      //a Toast message can be used to show item is selected
    }
    

提交回复
热议问题