安卓:菜单项自定义视图自定义、视图、菜单项

2023-09-12 03:03:33 作者:奋斗

我希望能够指定一个菜单项。

I want to be able to specify a custom view for a MenuItem.

我要显示在购物车中的菜单项,在操作栏中显示的许多项目是如何在车目前的指标。

I want to display an indicator on a shopping cart menu item in the action bar displaying how many items are in the cart currently.

是我能做到这一点的唯一方法是通过添加自定义视图,而不是利用菜单项的生命周期等?

Is the only way that I can do this is through adding a custom view instead of utilising the MenuItem lifecycle etc.?

推荐答案

要在菜单项叫setActionView(View视图)。

您可以提供要么是已经膨胀的视图或布局资源ID。

You can supply either an already inflated view or a layout resource ID.

 
精彩推荐
图片推荐