-1

Can anybody tell me, how to get a dialog popup (ColorPickerDialog) when i click on Button.

Code from comments:

  Button color = (Button)findViewById(R.id.color_button);
    color.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new ColorPickerDialog(getBaseContext(), mListener ,a ).show();
            System.out.println("button pressed");
        }
    });

   }),initialColor);
   dlg.show();

} });

I want select color , i done with spinner by using names. but i want more color's for that i have color picker dialog when i press on that button i want it will popup see in image: http://dl.dropbox.com/u/38493970/device-2011-08-23-134910.png

mauris
  • 42,982
  • 15
  • 99
  • 131
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
  • Looking at the question the answer seems straight-forward. Adding some code would help point out the exact problem. – Ron Aug 23 '11 at 07:13
  • Why are you not adding the code that i gave you? – Ron Aug 23 '11 at 08:46

2 Answers2

1

You can use this one http://code.google.com/p/color-picker-view/
EDIT:

button.setOnClickListener(new OnClickListener() {

 void onClick(View v) {
    // create the color picker dialog and display it.
    ColorPickerDialog dlg = new ColorPickerDialog(v.getContext(),new OnColorChangedListener()     {
          void colorChanged(int color) {
               mSelectedColor = color;
           }

       }),initialColor);
       dlg.show();
   }
});
Ron
  • 24,175
  • 8
  • 56
  • 97
  • that is different issue, i have color picker dialog, my requirement is popup the color picker dialog when i click on button. – RajaReddy PolamReddy Aug 23 '11 at 05:56
  • are u getting my question now. – RajaReddy PolamReddy Aug 23 '11 at 06:44
  • http://dl.dropbox.com/u/38493970/ColorPickerDialog.java i had button in FontActivity.class Button color = (Button)findViewById(R.id.color_button); color.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //new ColorPickerDialog(getBaseContext(), mListener ,a ).show(); //System.out.println("button pressed"); Intent intent = new Intent(FontActivity.this,ColorPickerDialog.class); startActivity(intent); } }); – RajaReddy PolamReddy Aug 23 '11 at 07:11
  • i added some code for u still why u gave negative mark, may be it's my problem because of i am new to android. already i have less reputation's for voting. – RajaReddy PolamReddy Aug 23 '11 at 07:22
  • Again you are not giving any details about the problem you have after adding my code. Please tell exactly what is happening when you run the code. Just saying "no, it's not working" does not help us. – Ron Aug 23 '11 at 07:48
  • sorry, after adding code it's not ready to run , with small modification's i run it gives forceClose error. – RajaReddy PolamReddy Aug 23 '11 at 07:50
1

there are lot of example i've found for you some of them are
Example 1
Example 2
Example 3
Example 4
Example 5
may this examples helpful to you..Happy coding..Thanks Pragna

Community
  • 1
  • 1
Android
  • 8,995
  • 9
  • 67
  • 108
  • Pragna thank's for u r reply, my requirement is i want to get the colorpickerdialog when i click on button. – RajaReddy PolamReddy Aug 23 '11 at 06:31
  • yes bt think simply in this example http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.html.create that class nw when you click on button then create this class object i think that will work – Android Aug 23 '11 at 06:37
  • or if you hva to any method to call frm that class then that cls name.self.methodname(); here in that class put this line before oncreate method public static clsname self; – Android Aug 23 '11 at 06:41
  • are you getting na?what i am trying to say – Android Aug 23 '11 at 06:41
  • i tried this , it's getting force close error.Intent intent = new Intent(this,ColorPickerDialog.class); startActivityForResult(intent,0); – RajaReddy PolamReddy Aug 23 '11 at 06:46
  • Intent intent = new Intent(your currentclsname.this,ColorPickerDialog.class); startActivity(intent);once try this also – Android Aug 23 '11 at 06:51
  • hve you tested the ColorPickerDialog cls displays dialong na? – Android Aug 23 '11 at 06:52