Search code examples
androidandroid-tvandroid-7.1-nougatleanback

Leanback GuidedStepFragment: How to get view of an action at startup


I have a GuidedStepFragment and I want to get view of one its actions (which is editable),cast it to EditText and hence set some of its parameters like TextColor programmatically.

So I should put this code at somewhere in the code:

    View v0 = getActionItemView(0);
    View v1 = v0.findViewById(R.id.guidedactions_item_title);
    final GuidedActionEditText v2 = (GuidedActionEditText) v1;
    v2.setTextColor(Color.RED);

I tried OnCreate , OnCreateView , ...(very trials actually) and each time I am facing to a NullPointerException saying the getActionItemView are returning Null!

At which function should I put this snippet to satisfy my need (i.e. change text color at fragment startup)?


Solution

  • I found the solution

    Just putted above code at onGuidedActionFocused method !