How to put a watch (see how a variable is modified) in Android Studio?

后端 未结 2 1073
逝去的感伤
逝去的感伤 2020-12-08 20:07

I don\'t know how to use a watch in Android Studio. I want to see how the value of a variable modifies through debugging. Does anyone know how to do this?

相关标签:
2条回答
  • 2020-12-08 20:42

    Start by putting a break point in the class where you'd want to watch a specific variable. Run the code and once it hits your breakpoint from the Variables window frame you should see all of the variables that are accessible. Simply choose the one you'd want to watch and then right click and choose "Add to watches" from the drop-down.

    enter image description here

    Keep debugging and you should see the variable from the Watches window frame update when appropriate based on your code.

    enter image description here

    0 讨论(0)
  • 2020-12-08 20:52

    Assuming you have the debug tabs selected:

    If you can't find the Watches View, it might be hiding in a few spots.

    Check the right side:

    If its not there, check the left side of the Variables tab:

    And if you don't find it in those places, then you can right click one of the variables at a breakpoint and choose "Add to watches" (as described in the accepted answer). After that the Watches View should either appear or be in one of the places I described above.

    0 讨论(0)
提交回复
热议问题