I defined theme and style inside my app. icons (drawable) are defined using reference in style file as
<attr name="myicon" format="reference" />
and style as
<style name="CustomTheme" parent="android:Theme.Holo">
<item name="myicon">@drawable/ajout_produit_light</item>
I need to retrieve the drawable programmatically to use the good image in a dialogfragment. If I make like
mydialog.setIcon(R.style.myicon);
I get an id equals to 0, so no image
I tried to use something like
int[] attrs = new int[] { R.drawable.myicon};
TypedArray ta = getActivity().getApplication().getTheme().obtainStyledAttributes(attrs);
Drawable mydrawable = ta.getDrawable(0);
mTxtTitre.setCompoundDrawables(mydrawable, null, null, null);
I tried different things like that but result is always 0 or null :-/
How I can I do this ?