user6761138
user6761138

Reputation:

How to Put label/Text in android action bar like showing wallet balance etc

I am creating a android application for recharging with different carriers from wallet inside the app! The wallet must have some balance to recharge. I almost completed the app but i need to show the wallet balance in my toolbar (action bar)

I will attach a pic:

Screen shot of the expected image

I need to achieve something like this!! Kindly provide me with any help!!

Upvotes: 1

Views: 331

Answers (1)

Aditya Vyas-Lakhan
Aditya Vyas-Lakhan

Reputation: 13555

You can set counter to toolbar. Try this way

@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

Upvotes: 1

Related Questions