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

后端 未结 2 1096
逝去的感伤
逝去的感伤 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

提交回复
热议问题