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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -