0

I`me sorry for stupid question...
How do xml works with java ???
For instance:

<TextView
    ...
    ...
    android:text="SuperMegaButton"
   />

In this example when compiler see android:text is it induce method from
"android.view.View.TextView" public void setText( ..... ) ??

Or as well

 < Any widget
        ...
        ...
        android:gravity="any_gravity"
     />

When compiler see android:gravity is it induce
public void setGravity(...)


Explain please in detail, because i am really confusing about that..
Thanks in advance

Anarantt
  • 289
  • 1
  • 2
  • 10
  • check source code. attributes comes to widget constructor where they parces and applied. widget decides how to apply them – Leonidos Dec 12 '14 at 14:02

2 Answers2

0

This is the job of inflaters. There are several questions on SO regarding the use of inflaters.

See for instance How to Inflate view from XML in Android? and How do I Inflate a Custom View in XML?

As for a detailed description you always have the docs. http://developer.android.com/reference/android/view/LayoutInflater.html

Community
  • 1
  • 1
Captain Giraffe
  • 14,407
  • 6
  • 39
  • 67
0

Your generated R.java file is the bridge between your XML and Java code. If you assign an ID to any View, Android Studio\Eclipse will automatically create an Integer ID for that view in your R.java file. You can assign IDs like this :

<TextView
    android:id="@+id\super_mega_button"
...
...
    android:text="SuperMegaButton"

/>

and get it with your Java code like this :

TextView textView = (TextView) findViewById(R.id.super_mega_button);

The phrase: (TextView) is responsible for Casting your xml code to Java.

A Honey Bustard
  • 3,433
  • 2
  • 22
  • 38