2012-02-09 79 views

回答

0

可以使用this project,而不是一個演示應用程序

// 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, initialColor, new OnAmbilWarnaListener() { 
     @Override 
     public void onOk(AmbilWarnaDialog dialog, int color) { 
       // color is the color selected by the user. 
     } 

     @Override 
     public void onCancel(AmbilWarnaDialog dialog) { 
       // cancel was selected by the user 
     } 
}); 

dialog.show(); 

要小心,這(我從來沒有用它自己):

你需要對Android 3.0的鏈接或更高,因爲有XML 屬性layerType正在使用中。這並不意味着您只能使用這個 來處理需要Android 3.0操作的應用程序。它甚至可以在Android 1.6的 中運行。您只需在 項目設置中選擇Android 3.0(API級別11)。

+0

它的工作原理,但我還有一個問題。如何在顏色改變後保存狀態?目前,當你按回顏色來擦除。 – 2012-02-10 20:49:10

+0

如果我理解你的評論,你需要把你的代碼放在'onOk(Dialog,int)'中。選擇的顏色是「int color」,你可以存儲它並做任何你想要的 – Raffaele 2012-02-10 22:50:07