jeudi 18 avril 2019

i want to switch images on same activity by clicking on them

hi every one i am creating a torch application i have 4 images on 1 activity first one the main image is laaltain when i click on it it turns on now i want to switch it with another image left most corner that will changes and turn on as well i have all images i am new if any of you know logic or terminology how to handle this please let me know Thank you@

i tried sending images via int but failed

here is a method of mine that changes images but not workingenter image description here

//Controling images
private void changeImageOfTublight()
{
    int m = R.drawable.on_laal_tain;
    int n = R.drawable.off_tubelight;
    if (m==main)
    {
        main = R.drawable.off_tubelight;
        main2 = R.drawable.on_tube_light;
        laaltain.setImageResource(main);
        tubelight.setImageResource(R.drawable.off_laaltain);
        m = R.drawable.off_tubelight;
    }
    else
        {
            main = R.drawable.off_laaltain;
            main2 = R.drawable.on_laal_tain;
            laaltain.setImageResource(main);
            tubelight.setImageResource(R.drawable.off_tubelight);
        }
}

Here is an image for your understanding

Aucun commentaire:

Enregistrer un commentaire