I have a class with an overridden toString()
method. It looks like this:
public class Foo {
private int debugInfo;
/* some code */
@Override
public String toString() {
return "some-string";
}
}
In debug tab in Android Studio, in 'Variables', it's represented as text from toString
:
Is it possible to have a custom message for the debugger to display in 'Variables'? I want to see the debugInfo
field value instead of the output from toString
, without having to click on the 'expand' arrow.
I know an analog exists in C# - it is the [DebuggerDisplay]
attribute:
[DebuggerDisplay("info = {debugInfo}")]
public class Foo
{
private int debugInfo;
}
Is there something similar for Java/Android?
When you debug, change toString()
like the following, and then you can change it back to whatever you like afterwards!
public class Foo {
private int debugInfo;
/* some code */
@Override
public String toString() {
return debugInfo;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With