Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓:什么&x27;这是“什么?”;“类”;是R.id.class.getFields()的?_Android_Class_Field - Fatal编程技术网

Android 安卓:什么&x27;这是“什么?”;“类”;是R.id.class.getFields()的?

Android 安卓:什么&x27;这是“什么?”;“类”;是R.id.class.getFields()的?,android,class,field,Android,Class,Field,我决定了解我复制和粘贴的内容,而不是盲目地复制和粘贴,我被R.id.class.getFields()卡住了!我最初的猜测是它将是一个静态的类变量,但是id类有这样的变量吗 R=R.java的R类 id=R.java的内部id类 类别= getFields()=Class.getFields()R.java是一个类。从资源中自动生成的类R.id正在访问内部类。公共静态最终类idR.id.class将为您提供一个R.id的类对象,getFields方法将返回类R.id中的所有public字段。看看

我决定了解我复制和粘贴的内容,而不是盲目地复制和粘贴,我被
R.id.class.getFields()
卡住了!我最初的猜测是它将是一个静态的
变量,但是id类有这样的变量吗

R=R.java的R类

id=
R.java的内部id类

类别=


getFields()=
Class.getFields()
R.java
是一个类。从
资源中自动生成的类
R.id
正在访问内部类。
公共静态最终类id
R.id.class
将为您提供一个R.id的类对象,
getFields
方法将返回类
R.id
中的所有
public
字段。看看
反射
机制


编辑:。

看看这个链接,它会给你一些想法:谢谢,但是在这种情况下,内部
id
没有成员变量(或者属性、字段等等)?这个主题当然很有趣。谢谢,但是我们如何通过点运算符(.)访问“类”?据我所知,它仅用于访问成员变量和方法(我假设它最终与Android无关)。R.id.class将为您提供一个class对象。谢谢,我们似乎可以通过.class.First part reflection;,从静态类或原语类型中获得class对象。)所有的定义都在这里,我想你可以按照你想学习的内容来浏览整个主题
Class Overview
The in-memory representation of a Java class. This representation serves as the starting point for querying class-related information, a process usually called "reflection". There are basically three types of Class instances: those representing real classes and interfaces, those representing primitive types, and those representing array classes.

Class instances representing object types (classes or interfaces)

These represent an ordinary class or interface as found in the class hierarchy. The name associated with these Class instances is simply the fully qualified class name of the class or interface that it represents. In addition to this human-readable name, each class is also associated by a so-called signature, which is the letter "L", followed by the class name and a semicolon (";"). The signature is what the runtime system uses internally for identifying the class (for example in a DEX file).

Classes representing primitive types

These represent the standard Java primitive types and hence share their names (for example "int" for the int primitive type). Although it is not possible to create new instances based on these Class instances, they are still useful for providing reflection information, and as the component type of array classes. There is one Class instance for each primitive type, and their signatures are:

B representing the byte primitive type
S representing the short primitive type
I representing the int primitive type
J representing the long primitive type
F representing the float primitive type
D representing the double primitive type
C representing the char primitive type
Z representing the boolean primitive type
V representing void function return values
Classes representing array classes

These represent the classes of Java arrays. There is one such Class instance per combination of array leaf component type and arity (number of dimensions). In this case, the name associated with the Class consists of one or more left square brackets (one per dimension in the array) followed by the signature of the class representing the leaf component type, which can be either an object type or a primitive type. The signature of a Class representing an array type is the same as its name. Examples of array class signatures are:

[I representing the int[] type
[Ljava/lang/String; representing the String[] type
[[[C representing the char[][][] type (three dimensions!)