Hello all- I am trying to make a color chooser application so my users can compile their selected colors in to a list that I can use in my interpreter. I am using the ambilwarna dialog for the color chooser. I have made 10 box.xml files (box1.xml, box2.xml etc..) and formatted them to be small red squares. Below is my code. My question is, how do I get color chosen from ambilwarna dialog and send that color to my box1.xml android:color tag?
package com.example.testercolor; import yuku.ambilwarna.AmbilWarnaDialog; import yuku.ambilwarna.AmbilWarnaDialog.OnAmbilWarnaListener; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity { private Button colorShow1; private Button colorShow2; private Button colorShow3; private Button colorShow4; private Button colorShow5; private Button colorShow6; private Button colorShow7; private Button colorShow8; private Button colorShow9; private Button colorShow10; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Getting reference to the button colorShow1 = (Button) findViewById(R.id.color1); colorShow2 = (Button) findViewById(R.id.color2); colorShow3 = (Button) findViewById(R.id.color3); colorShow4 = (Button) findViewById(R.id.color4); colorShow5 = (Button) findViewById(R.id.color5); colorShow6 = (Button) findViewById(R.id.color6); colorShow7 = (Button) findViewById(R.id.color7); colorShow8 = (Button) findViewById(R.id.color8); colorShow9 = (Button) findViewById(R.id.color9); colorShow10 = (Button) findViewById(R.id.color10); // Defining click event listener for the button OnClickListener clickListener = new OnClickListener() { @Override public void onClick(View v) { colorpicker(); } }; // Setting click event listener for the button colorShow1.setOnClickListener(clickListener); colorShow2.setOnClickListener(clickListener); colorShow3.setOnClickListener(clickListener); colorShow4.setOnClickListener(clickListener); colorShow5.setOnClickListener(clickListener); colorShow6.setOnClickListener(clickListener); colorShow7.setOnClickListener(clickListener); colorShow8.setOnClickListener(clickListener); colorShow9.setOnClickListener(clickListener); colorShow10.setOnClickListener(clickListener); } public void colorpicker() { // initialColor is the initially-selected color to be shown in the rectangle on the left of the arrow. // for example, 0xff000000 is black, 0xff0000ff is blue. Please be aware of the initial 0xff which is the alpha. AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, 0xff0000ff, new OnAmbilWarnaListener() { // Executes, when user click Cancel button @Override public void onCancel(AmbilWarnaDialog dialog){ } // Executes, when user click OK button @Override public void onOk(AmbilWarnaDialog dialog, int color) { Toast.makeText(getBaseContext(), "Selected Color : " + color, Toast.LENGTH_LONG).show(); } }); dialog.show(); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en