How to compare 2 button backgrounds in Android? -
so have 2 buttons (or imagebuttons or can use background) same background. want method check whether have same background or not.
i tried 2 buttons same background,
button1.getbackground(); button2.getbackground();
but both returned different values.
any other methods?
the getbackground()
method returns drawable
object.
now compare 2 drawable
objects best use getconstantstate()
method obtain them. should work.
button1.getbackground().getconstantstate().equals(button2.getbackground().getconstantstate())
Comments
Post a Comment