samedi 4 juillet 2020

How do I sent data from checkbox to Main2activity

I want sent color to another activity

This I touch ImageView for get color and setBackgroundColor show on checkbox

   public boolean onTouch(View view, MotionEvent motionEvent) {

            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN || motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
                counter++;
                bitmap = mImageView.getDrawingCache();
                int pixel = bitmap.getPixel((int) motionEvent.getX(), (int) motionEvent.getY());

                int r = Color.red(pixel);
                int g = Color.green(pixel);
                int b = Color.blue(pixel);

                if (counter == 1) {
                    checkBox1.setBackgroundColor(Color.rgb(r, g, b));
                    checkBox1.setText("R:" + r + " G:" + g + " B:" + b);

                } else if (counter == 2) {
                    checkBox2.setBackgroundColor(Color.rgb(r, g, b));
                    checkBox2.setText("R:" + r + " G:" + g + " B:" + b);
                } else if (counter == 3) {
                    checkBox3.setBackgroundColor(Color.rgb(r, g, b));
                    checkBox3.setText("R:" + r + " G:" + g + " B:" + b);
                }
            }

            return true;
        }

Then I want choose one or many color from checkbox and sent to Main2activity and show on TextView

      mSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Main3Activity.this,Main4Activity.class);      
            startActivity(intent);
        }
    });
}



Aucun commentaire:

Enregistrer un commentaire