gpt4 book ai didi

android - 如何在 android 操作栏中放置标签/文本,如显示钱包余额等

转载 作者:行者123 更新时间:2023-11-30 00:41:07 25 4
gpt4 key购买 nike

我正在创建一个安卓应用程序,用于从应用程序内的钱包中使用不同的运营商进行充电!钱包必须有一些余额才能充值。我几乎完成了该应用程序,但我需要在我的工具栏(操作栏)中显示钱包余额

我会附上一张照片:

Screen shot of the expected image

我需要实现这样的目标!!请向我提供任何帮助!!

最佳答案

您可以将计数器设置为工具栏。试试这个方法

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

//you can add some logic (hide it if the count == 0)
if (badgeCount > 0) {
ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyles.DARK_GREY, badgeCount);
} else {
ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));
}

//If you want to add your ActionItem programmatically you can do this too. You do the following:
new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);
return super.onCreateOptionsMenu(menu);
}

https://github.com/mikepenz/Android-ActionItemBadge

enter image description here

关于android - 如何在 android 操作栏中放置标签/文本,如显示钱包余额等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42571503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com