更新时间:2023-11-19 12:56:04
这不建议将您的对象标识自己,findViewById使访问您的R舱,其中包含指向您的XML项目的ID。
It's not recommended to set your object id yourself , findViewById make access to your R class that contains pointers to your XML items id.
当你定义你的XML布局文件中的一个ID像
when you define an id in your Xml Layout file like
android:id="@+id/txtyourId"
在编译的时候编译器创建一个参照R舱您的XML项目的布局,你可以从你的java code。通过findViewById访问
in compile time compiler create a reference to your XML Item layout in R class that you can access it from your java code by findViewById
View YourItem = (View)this.findViewById(R.id.txtyourId);