Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.

FAB label programatically - not workin #85

Closed
@ivanviragine

Description

@ivanviragine

Hi there,

I'm trying to show the label of the button's programatically, only when user opens the app for the first time. So, I can do this two ways:

  1. Put the labels on XML and hide then programatically if it's not the first time
  2. Don't put the label on XML and show it if it's the first time

The 2) way makes more sense.
Neither can get me there.
Solution 1), when I set the label to null or "", the label appears empty (it should not even appear)
Solution 2), when I set the label programmatically, it doens't show (show empty, like on 1))

Am I missing something?

A little code:

  1.  if (fab != null && !app().getFirstLaunch()) {
         FloatingActionButton button = null;
    
        for (int i = 0; i < fab.getChildCount(); i++) {
            if (fab.getChildAt(i) instanceof FloatingActionButton) {
                button = (FloatingActionButton) fab.getChildAt(i);
                button.setLabelText(null);
            }
        }
    }
    if (fab != null && app().getFirstLaunch()) {
        ((FloatingActionButton) fab.getChildAt(0)).setLabelText(getString(R.string.fab_photo));
        ((FloatingActionButton) fab.getChildAt(1)).setLabelText(getString(R.string.fab_search));
        ((FloatingActionButton) fab.getChildAt(2)).setLabelText(getString(R.string.fab_notifications));
        ((FloatingActionButton) fab.getChildAt(3)).setLabelText(getString(R.string.fab_profiles));
        ((FloatingActionButton) fab.getChildAt(4)).setLabelText(getString(R.string.fab_feed));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions