我正在创建一个安卓应用程序与不同的运营商从应用程序内的钱包充电!钱包必须有一些余额才能充值。我几乎完成了应用程序,但我需要在我的工具栏(操作栏)中显示钱包余额
我会附上一张照片:
Screen shot of the expected image
我需要实现这样的事情!!请为我提供任何帮助!
发布于 2017-03-03 13:49:00
您可以将计数器设置为工具栏。试试这条路
@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

https://stackoverflow.com/questions/42571503
复制相似问题