英文:
How to get field name in android
问题
我正在创建一个相机应用,希望记录有关相机状态的信息。现在我正在使用:
Log.i("AF状态", String.valueOf(result.get(CaptureResult.CONTROL_AF_STATE)));
它返回类似以下的值:
I/AF状态: 1
这很难阅读,我想知道是否有一种方法可以记录这些数字代表的字段名称,例如:
I/AF状态: CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
英文:
I'm creating camera app and I want to log infos about camera state. Now I'm using:
Log.i("AF state", String.valueOf(result.get(CaptureResult.CONTROL_AF_STATE)));
It returns values like:
I/AF state: 1
It is hard to read and I'm curious if there is a way to log field names that these numbers represent, for example:
I/AF state: CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
答案1
得分: 0
你可以使用 getName()
Log.i("AF 状态", result.get(CaptureResult.CONTROL_AF_STATE).getName());
返回一个驼峰式、点分隔的名称格式,类似于:
"root.section[.subsections].name"。
英文:
You can use getName()
Log.i("AF state", result.get(CaptureResult.CONTROL_AF_STATE).getName());
Return a camelCase, period separated name formatted like:
"root.section[.subsections].name".
专注分享java语言的经验与见解,让所有开发者获益!
评论