Turning ImageButton to toggled one

Was trying to make ImageButton s “toglable”. Recipes are everywhere and I made such program: https://github.com/dims12/TryInvestigateButtonUnpress

It shows “pressed” button by

protected void onCreate(Bundle savedInstanceState) {



And looks the following way:


Unfortunately, once I press “Home” button on the device, button turns unpressed. This happens even before application actually minimizes.

The solution for this appeared simple: I was to simulated toggle not with “pressed”, but with “selected” attribute.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s