在三星手機上調試我的應用程序,出現奇怪的結果,我沒有物理訪問權限。我想問一個用戶運行一個儀器化的應用程序來幫助調試。我的應用得到了一個view
,它有一個未知的(對我來說,-)層次結構(ViewGroups
等)。有沒有辦法「走」View
並打印出一個字符串/ ddms
View
(etc等ViewGroups
等)中的所有組件?打印設備上的視圖層次結構
這將類似於HierarchyViewer
工具 - 如果我有adb
級別訪問設備。
更新:我想我可以使用的方法
void dumpViewHierarchyWithProperties(Context context, ViewGroup group, BufferedWriter out, int level)
從ViewDebug.java
Android操作系統源...
任何人有一個更好的主意嗎?
謝謝!
我會給+2 ups只在var名稱中使用$,我認爲這是不可能的,從來沒有嘗試過。 –
我喜歡這個答案,但我會更好地使用以下內容,以便您可以打印該ID(如果可用): 'String desc = $ prefix +「|」+「[」+ i +「 /「+($ vg.getChildCount() - 1)+」]「+ v.getClass()。getSimpleName(); String id = null; try { id = v.getResources()。getResourceName(v.getId()); desc + =「」+(id == null?v.getId():id);}} catch(Exception e){ // no-op(no id found) } ' – Jun
@Marcos:Java不是PHP ... –