Search code examples
androidlayout-inflater

Are Views automatically inflated?


From what I understand, the LayoutInflater converts XML into Views. But when I use Buttons, TextViews or other widgets in code, I simply have to use findViewById() without having to inflate these Views first. Are these views automatically inflated? If so, when are views automatically inflated and when do you have to inflate them manually?


Solution

  • You just have to inflate an xml layout, and then all the viewgroups and views (buttons,textview,edittext,etc.) will automatically be shown.

    So in an Activity class, oncreate method has a line SetContentview(), this inflates the xml layout.