Q:

Android ImageButton's image to be replaced with another image

I have an ImageButton and I want that onClick would replace it with another image (flip back and forth) and on a long press, would replace it to another image.
How can I do that?
I don't feel like reading long documentaries for this.

A:

Set onClickListeners for your button then change the drawable. Since you don't have any code, the following is based on a dynamic ImageButton that only outlines how to perform the action you want. I suggest you define your ImageButton in your XML layout first and then use
 iBtn = (ImageButton) findViewById(R.id.btnID); 
ImageButton iBtn = new ImageButton(this);
        iBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                iBtn.setImageDrawable(getResources().getDrawable(R.drawable.img1);

            }
        });
        iBtn.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                iBtn.setImageDrawable(getResources().getDrawable(R.drawable.img2);
                return true;
            }
        });

