1

I'm implementing a library that will make use of MVVM design pattern easier in Android. For binding I need to read custom attributes on existing views. It is possible with LayoutInflater.Factory (Custom XML attributes without custom View in Fragment)

But as you can see in onCreateView (String name, Context context, AttributeSet attrs) header there is no View in arguments and I need it in my case... How do I get it? Should I create it myself?

How do I do it so I get equivalent of "default behavior" (as in "Return null for the default behavior")?

Community
  • 1
  • 1
zduny
  • 2,481
  • 1
  • 27
  • 49

1 Answers1

0

Get the activity from the onAttach and get the View on that activity

example:

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    this.activity = activity;
}

get the View from activity:

this.activity.getWindow().getDecorView()
Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63