Question: In my android project i have taken 2 image button(start and stop).
when i pressed START IMAGE BUTTON then it converted to STOP IMAGE BUTTON BUT again when i pressed STOP IMAGE BUTTON it does not converted into START BUTTON.so let me know where is the problem.

```
  mImageButton.setOnFocusChangeListener(
  new OnFocusChangeListener()
  {
  @Override
  public void onFocusChange(View v, boolean hasFocus) {
  // TODO Auto-generated method stub
  if (hasFocus==true)
  {
      mImageButton.setImageResource(R.drawable.stop);
  }
 else
 {
  mImageButton.setImageResource(R.drawable.play);
 }
  }
 });

 mImageButton.setOnClickListener(
 new OnClickListener() {
 @Override
 public void onClick(View v) {
 // TODO Auto-generated method stub
 mImageButton.setImageResource(R.drawable.stop);
   }
   });     
 }
}

```

Answer: 
In Android `onFocusChange` is called before `onCLick`. Whatever you set in the `onFocusChange` method is ignored, as the `onClick` will be called next, and it changes the image bak to `R.drawable.stop`.

You shouldn't use `onFocusChange` at all for what you are trying to do. Only use onClick instead.

```
private boolean pCurrentlyPlaying = false;

...

mImageButton.setOnClickListener(
    new OnClickListener() {
       @Override
       public void onClick(View v) 
       {
           int image = pCurrentlyPlaying ? R.drawable.stop : R.drawable.play;
           mImageButton.setImageResource(image);
           pCurrentlyPlaying = !pCurrentlyPlaying ;
       }
    });    

```

You can also use the ToggleButton, [here is an example](https://stackoverflow.com/a/2751320/1821029) of how to define it in XML.
Try This Code.. May Be Help You.

```
 boolean isStart = true ;
 boolean isStop = false;
 mImageButton.setOnClickListener(
 new OnClickListener() {
 @Override
 public void onClick(View v) {
// TODO Auto-generated method stub
 if(isStart){
 isStart =false ;
 isStop = true ;
 mImageButton.setImageResource(R.drawable.play);
 }else{
 isStart = true ;
isStop = false;
mImageButton.setImageResource(R.drawable.stop);
 }
}
});     
}
}

```