user2841300
user2841300

Reputation: 353

How to set individual colors in the Activity in android?

I am working on paint application .I am using a colorpickerdialog for picking colors and it is also working fine .Now I am trying to fix only three colors (red,blue,green) in the Activity.

How can I fix three colors in the Activity?

This image consists of all separate colors in the same activity

This image consists of more colors in the same activity.This is what I am looking for could anyone help me how to do this or give any same program for this?

Upvotes: 1

Views: 68

Answers (1)

vipul mittal
vipul mittal

Reputation: 17401

Have three TextViews with Red, Green and Blue in your activity set onClick listener for all of them and in onClick:

    int currentColor=Color.RED;

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.red:
        currentColor=Color.RED;
        break;
       case R.id.green:
        currentColor=Color.GREEN;
        break;
       case R.id.blue:
        currentColor=Color.BLUE;
        break;

    default:
        break;
    }

}

Upvotes: 1

Related Questions