I’d like to do a kind of ToggleImageButton, by that I mean a button which stay down when it’s pressed and which gets its original state when we click it again. And I have two images for the “normal” state and the “down” state. For the moment I use an ImageButton, and I call setImage to change the image when the button is clicked, but it’s not working. Can somebody tell me the best way to do it? Thanx
yep, but It crashed when I called setImage(). But I 've found another way to do it, I create a subclass of Button, and in the “paintButton” method, I draw my images depending on its state. No sure that’s the best way, but it works. Thanks for answering.
[quote=“leskimo”]yep, but It crashed when I called setImage(). But I 've found another way to do it, I create a subclass of Button, and in the “paintButton” method, I draw my images depending on its state. No sure that’s the best way, but it works. Thanks for answering.
Leskimo[/quote]
…ugh. So you’ve written your own version of something that already works… Have a look at the demo app, where it has buttons like this. If it’s crashing then you’re probably passing it a dodgy image pointer or deleting the image when you shouldn’t.
the “down” image isn’t the same as the “toggled-on” image. Any button can be made to toggle, but the imagebutton doesn’t actually let you specifiy different images for its different toggle states. The DrawableButton does, so you could just use one of those. I thought you were asking about it in a more general sense!