In case setEnabled of Button doesnt work in Android

You can enable or disable (gray out ) a button with setEnabled method of Button class. In my case i needed to enable a button depending on a network call result. Although i call setEnabled(true), button didnt become enabled. When i touch the button, it become enabled. After some investigation, i noticed that i needed to use runOnUIThread when calling setEnabled. Then setEnabled worked. Hope this helps to developers that encounter same problem.

admin Hakkında

Murat Aydin works as a senior software engineer at Arcelik and develops Android apps. He has several Android applications in Google Play. He is a Sun Certified Java Developer and has eight years of experience in developing web based applications using Java technologies, and desktop and engineering applications using .Net technologies. Murat Aydin earned his BSc degree in Computer Engineering from METU (Middle East Technical University) and his MSc degree in Software Engineering from METU. He is a member of GDG Ankara (Google Developer Group Ankara, www.gdgankara.org), who organize several Android events in GDG Ankara, such as Android Developer Days. (www.androiddeveloperdays.com). twitter: @maydintr gmail: maydin