Question: I want to change the images in image view on `Onclick` function. I have already tried this:

```
bt_audiocapture.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {

            if (checkPermission()) {

                if (bt_audiocapture.getResources().getDrawable(R.drawable.ic_mic).equals(R.drawable.ic_mic)) {
                    start();
                    bt_audiocapture.setImageResource(R.drawable.ic_stop);
                } else if (bt_audiocapture.getResources().getDrawable(R.drawable.ic_stop).equals(R.drawable.ic_stop)) {
                    stop();
                    bt_audiocapture.setImageResource(R.drawable.ic_play);
                } else if (bt_audiocapture.getResources().getDrawable(R.drawable.ic_play).equals(R.drawable.ic_play)) {
                    play();
                }
            }
        }
    });

```

Answer: 
`bt_audiocapture.getResources().getDrawable(R.drawable.ic_mic)` returns a `Drawable` object. You can't compare it to `R.drawable.ic_mic`, which is `integer`. That is something like comparing a `car` to `green color`. 

To accomplish your task, make some field like `private int state = 0;`, and some constants like 

```
private final STATE_PLAYING = 1;
private final STATE_STOPPED = 2;
private final STATE_NONE = 0;

```

and then: 

```
if (state == STATE_NONE) {
    start();
    bt_audiocapture.setImageResource(R.drawable.ic_stop);
    state = STATE_PLAYING;
} else if (state == STATE_PLAYING) {
    stop();
    bt_audiocapture.setImageResource(R.drawable.ic_play);
    state = STATE_STOPPED;
} else if (state == STOPPED) {
    play();
    state = STATE_PLAYING;
}

```
Your `equals` expressions always return false, I would expect that none of your `if` blocks is executed. Did you debug that code?

I would suggest to keep the state in another variable, e.g. with an `enum`.

Additionally you should use `setImageDrawable` for performance reasons. See the javadoc of `setImageResource`: 

> 
> This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup
> 
> 
>