1

我刚开始作为一名 Android 开发人员工作。我的第一个任务是修复 App 调用 DailyFinance 的几个错误。

一个错误是与 UI 相关的,如果您单击某个页面上的按钮,会弹出一个对话框,但该对话框无法正确显示。我的问题是如何在我不熟悉的代码库中快速找到与对话框相关的代码(xml 布局文件以及活动)?

4

2 回答 2

2

想到了几种方法:

  1. 搜索显示在目标对话框上的任何文本。
  2. 搜索按钮文本并找到包含启动目标对话框的按钮的 xml 布局文件
  3. 找到 xml 布局文件后,确定按钮 'id' 为 xxxxx,然后您可以进一步搜索包含对 'R.id.xxxxx' 的引用的源
于 2012-08-14T23:15:53.537 回答
1

Set breakpoints on methods in files that implement the dialog. So maybe search for dialog and then put breakpoints inside the dialog. See it it gets hit when your dialog gets pulled up. Or just see where the layouts are set in files that have the word dialog in them. look for R.layout.someLayoutName.

One other suggestion is for some difficult layouts where its tough to see whats going on you can use the HierachyViewer to see the runtime view layouts: http://developer.android.com/tools/help/hierarchy-viewer.html Its worth running on your app to see the structure of the layouts at runtime which is often hard to see these relationships in the layout files before they have been inflated.

BTW, I was a student of CS and the biggest mistake I ever made was not to learn the debugger inside and out. Its without a doubt the most powerful ally you have to learn as well as fix bugs. If you think about it, code really is only an abstraction until you see it running inside the debugger.

于 2012-08-14T23:43:52.837 回答