Question

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?

Était-ce utile?

La solution

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;
    }

}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top