I am a beginner of android development. Current, I am working on creating a small home screen widget that is changing wallpaper of the mobile on click the button. The setting wallpaper is working fine but I want to make a clickable small picture (ImageView) to allow user to show and hide this setting button.
I setup it on service and use PendingIntent in order to attach my onClick event to the same service, but I cannot detect the property of button whether showing or hiding.
Therefore,is there any suggestion and solution to make my ImageView to show or hide the button in home screen widget?
Thanks in advance..
You can use mButton.setVisibility(View.GONE) to hide the button.
You can also check state of button’s visibility in a boolean variable using mButton.isShown().
Edited:
For Example
In
onReceive()ofAppWidgetProvider,So for hiding your Button
Edit – 2: According to Kartik’s comment,
Sample Code: