views:

35

answers:

2

Im working on changing the image being shown when I have my ImageView Clicked. Im trying to use a similar code that I used for accomplishing this with a TextView but I can't seem to find the right terms to get it to work. Here is my current code. Thanks

electronconfiguration.setOnClickListener(new View.OnClickListener() {

    public void onClick(View drawable) {

        if (drawable.equals(R.drawable.element_el))
        electronconfiguration.setImageDrawable(R.drawable.aluminum_el);

        else if (drawable.equals(R.drawable.aluminum_el))
        electronconfiguration.setImageDrawable(R.drawable.element_el);
    }
});
A: 

Why don't you use a ViewSwitcher, it's designed to switch between two views

fedj
A: 

drawable probably doesn't equal R.drawable.element_el. R.drawable.element_el is probably some random implementation of the image. Try drawable.getId().equals(R.drawable.element_el). I've never tried this so I have no idea

Falmarri
for now i have changed it to be a image button and i have it changing from one image to a second but have no clue how to get back to the first. Any idea how to check which image is showing and have it show the opposite?
Joshua Sutherland