Android ActionBar compatibility: MenuItem.setActionView(View)

前端 未结 1 1930
离开以前
离开以前 2021-01-05 15:39

I\'m using the appcompat7 lib for ActionBar backwards compatibility. Now I have a MenuItem that I retrieve, and then want to set an ImageView myView

相关标签:
1条回答
  • 2021-01-05 16:13

    Look at MenuItemCompat: http://developer.android.com/reference/android/support/v4/view/MenuItemCompat.html

    There is a static function setActionView(MenuItem item, View view)

    So your code should look like:

    MenuItem menuItemRefresh = menu.findItem(R.id.refresh);
    menuItemRefresh = MenuItemCompat.setActionView(menuItemRefresh, myView);
    
    0 讨论(0)
提交回复
热议问题