Android Class "this" 个组件
Android Class "this" components
当我在 class 方法中记录“this”时
Log.i(TAG, "this:"+this);
结果是:
this:android.myapp.MyView{43354c80 V.ED.... ........ 0,9-104,61 #7f0b0005 app:id/myViewID}
具有字段
43354c80 - ?
V.ED.. ....... - ?一些位域,V 可能是 Visibility
0,9-104,61 - 剪辑矩形
#7f0b0005 - ?
app:id/myViewID - R.id.*
“?”是什么意思?日志中 "this" 的字段?
=== 编辑 ===
因为所有的评论都看不到,所以我写了来自@Blackbelt answer & comments 的完整答案。
在这种情况下:
43354c80 - hashCode()
的结果
V - 可见
E - 启用
D - 取决于 setWillNotDraw()
0,9-104,61 - 绘制矩形
7f0b0005 - getId() 的结果
app:id/myViewID - id 作为字符串
如您所见,您在日志中看到的是 View
中 Object#toString()
的覆盖版本:
V
停留 View.VISIBLE
E
停留 ENABLED
final int id = getId();
if (id != NO_ID) {
out.append(" #");
out.append(Integer.toHexString(id));
它是View的id toHex。你可以阅读完整的方法here
当我在 class 方法中记录“this”时
Log.i(TAG, "this:"+this);
结果是:
this:android.myapp.MyView{43354c80 V.ED.... ........ 0,9-104,61 #7f0b0005 app:id/myViewID}
具有字段
43354c80 - ?
V.ED.. ....... - ?一些位域,V 可能是 Visibility
0,9-104,61 - 剪辑矩形
#7f0b0005 - ?
app:id/myViewID - R.id.*
“?”是什么意思?日志中 "this" 的字段?
=== 编辑 ===
因为所有的评论都看不到,所以我写了来自@Blackbelt answer & comments 的完整答案。
在这种情况下:
43354c80 - hashCode()
的结果
V - 可见
E - 启用
D - 取决于 setWillNotDraw()
0,9-104,61 - 绘制矩形
7f0b0005 - getId() 的结果
app:id/myViewID - id 作为字符串
如您所见,您在日志中看到的是 View
中 Object#toString()
的覆盖版本:
V
停留 View.VISIBLE
E
停留 ENABLED
final int id = getId();
if (id != NO_ID) {
out.append(" #");
out.append(Integer.toHexString(id));
它是View的id toHex。你可以阅读完整的方法here