Meaning of R.layout.activity_main in android development (JAVA language)

后端 未结 5 1969
清酒与你
清酒与你 2020-12-31 09:25

What is the meaning of R.layout.activity_main ?

I understand that \".\" operator is used to define variables of a particular object but in this case its been used t

5条回答
  •  自闭症患者
    2020-12-31 10:19

    From https://stackoverflow.com/a/4953282/1393766

    R is a class containing the definitions for all resources of a particular application package. It is in the namespace of the application package.

    If you want to inflate a layout inside your activity class,you can use R.layout.activity_main where layout specifies that your resource is a layout and it's name is activity_main.

    If you want to use a drawable image in a layout inside your activity class,you can use R.drawable.image_name where drawable specifies that your resource is a drawable image.

    Also,R.java class is an autogenerated class which is not supposed to alter manually.

提交回复
热议问题