Como criar um objeto Drawable com a cor selecionada no código
Estou tentando definir o ícone da cor selecionada com uma preferência:
Preference prf = (Preference) findPreference("SelectColorPref");
prf.setIcon(Drawbale icon);
Para isso, preciso de um objetoDrawable
da cor selecionada.
É possível fazer umDrawable
ícone no código java? Por favor me guie.
Saudações
/////////////////////////////////////////////////// //////////
Após seguir o conceito de Aleks G, ele resolveu como:
Preference TextClrPref = (Preference) findPreference("text_color_preference");
Bitmap bm = Bitmap.createBitmap(30, 30, Bitmap.Config.ARGB_8888);
Canvas cnv = new Canvas(bm);
int red = 0xffff0000;
cnv.drawColor(red);
Drawable drawable = new BitmapDrawable(bm);
TextClrPref .setIcon(drawable);