Brian Tkatch wrote:I'm no expert. Still learning myself!
When using Android Studio, though, you can see the logs. Also, using Log.d() to specify a tag, and then filter on that tag to see what is going on. You can check if you are making it to onCreate(), at the very least.
When using Android Studio, though, you can see the logs. Also, using Log.d() to specify a tag, and then filter on that tag to see what is going on. You can check if you are making it to onCreate(), at the very least.
Dave Tolls wrote:Why aren't you using a ToggleButton?
That would get rid of the whole logic around visible/invisible and the isOn flag.
You could then also use onCheckedChange instead of onClick.
Dave Tolls wrote:Instead of having two ImageButtons you'd have a ToggleButton.
Instead of using onClick you'd use the onCheckChanged (I think that's the method) which gives you the View (ie ToggleButton) and the new value (on or off).
You can remove the isOn flag.
Inside the listener (now onChange) you'd not worry about the visible/invisible stuff (so throw that away) you'd just worry about the flash bit:
Note that that is not copy/paste code!
Consider Paul's rocket mass heater. |