Skip to content Skip to sidebar Skip to footer

Toggle Image In Imageview On Double Tap

i want to toggle image in imageview, i have tried several methods and failed.. this is the code.. there are 2 problems.. 1) the on click listner is faulty.. 2) the condition if(i

Solution 1:

OK try this

First you need a boolean to determine which image is there

Booleanflag=false;

Then implement onDoubleTap() like this:

@OverridepublicbooleanonDoubleTap(MotionEvent event) {
    if(flag){
        image.setImageResource(R.drawable.highmaths);
        flag=false;
    }else{
        image.setImageResource(R.drawable.lowmaths);
        flag=true;
    }
    returntrue;
}

Hope this helps :)

Post a Comment for "Toggle Image In Imageview On Double Tap"