2

I'm developing an Android TV application which is using Leanback library. There is a login form with email, password and a login button. I'd like to enable the login button only when the email and password are valid.

Here is my code:

mLoginButtonAction = new GuidedAction.Builder(this.getActivity())
            .id(id)
            .title(title)
            .description(desc)
            .build();
actions.add(action);

I disable it at first:

mLoginButtonAction.setEnabled(false);

And then enable it when it's valid:

mLoginButtonAction.setEnabled(valid);

The button is then enabled and I'm able to click it. But the color of the button is still the same color as in disable mode. Any idea? Thanks.

enter image description here

Bagusflyer
  • 12,675
  • 21
  • 96
  • 179

1 Answers1

5

Modification to actions do not trigger notifications to the GuidedStepFragment and must be done so manually.

To notify an action change you first need the items index.

int idx = findActionPositionById(actionId);

Get and modify your action

GuidedAction someAction = getActions().get(idx);
someAction.setEnabled(valid);

Next notify the fragment of the update

notifyActionChanged(idx);
ian.shaun.thomas
  • 3,468
  • 25
  • 40