What is the correct term when calling a widget from xml in Android?

I'm still very new to Android, but I try to keep up with the tutorials on YouTube. A bunch of people throw the phrase "inflate xml". I also started using this phrase, and it seems to me that I'm not doing it right.

The only time I say "inflate xml" is when someone writes code to use the widget from xml in java code.

So, if I see a button on someones layout, with id button01, and I tell them to "inflate xml", I expectButton mybutton = (Button) findViewById(R.id.button01);

Is that not so?

EDIT: This doesn't seem to be the right phrase. Does it exist?

0
source share
3 answers

"" Android XML , .

"" , :

  • XML

    //main.xml

  • =       (LayoutInflater) getSystemService (Context.LAYOUT_INFLATER_SERVICE);

   View view = inflator.inflate(R.layout.main)

, "findViewById"

    Button mybutton = (Button) view.findViewById(R.id.button01);

Activity ,

    setContentView(R.layout.main)

"setContentView" , "findViewById"

+3

. - , (, , xml), , , :

View view = getLayoutInflater().inflate(R.layout.mylayout, null);

:

LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

Button mybutton = (Button) view.findViewById(R.id.button01);
+1

Button mybutton = (Button) findViewById (R.id.button01);, , , , xml.

, "" . , XML-, , Java-.

0

All Articles