Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.rigault.colormix.view;
- import java.util.Observable;
- import java.util.Observer;
- import nl.rigault.colormix.R;
- import nl.rigault.colormix.model.ColorModel;
- import android.content.Context;
- import android.graphics.Color;
- import android.util.AttributeSet;
- import android.view.LayoutInflater;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- public class RGBColorView extends LinearLayout implements Observer {
- private ColorModel model;
- private ImageView colorMixImage;
- public RGBColorView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init();
- }
- private void init() {
- LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- inflater.inflate(R.layout.rgbcolorview, this);
- colorMixImage = (ImageView) findViewById(R.id.ColorMixView);
- model = ColorModel.getInstance();
- }
- @Override
- public void update(Observable arg0, Object arg1) {
- colorMixImage.setBackgroundColor(Color.rgb(model.getR(), model.getG(), model.getB()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement