'How to make an image changing object in Android Studio?

public class Heart {
enum HRanks{
    ACE(1),
    TWO (2),
    THREE(3),
    FOUR(4),
    FIVE(5),
    SIX(6),
    SEVEN(7),
    EIGHT(8),
    NINE(9),
    TEN(10),
    JACK(11),
    QUEEN(12),
    KING(13);

    int rank;
    String color;
    ImageView cardView;


    HRanks (int r){

        this.rank = r;
    }

    public String setColor(String c){
        return c;
    }

    public void setImage(View view){
        ImageView defaultView = (ImageView) view;
        defaultView.setImageResource(R.drawable.x);
    }


  }
}

I got 3 other classes for Spades, Clubs, and Diamonds. I am at the beginning of the developing klondike game app. For now, I am assigning two images for each card. One, when the card is faceUp and second when the card is faceDown. For setImage method, can I have a variable x that changes each card's image value based on user input?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source