I'm trying to use Java (not XML) to add system drawable to a layout and I am able to do this in xml part but can't figured out how do I add system drawable in java ?
in Xml
android:Drawable="@android:drawable/cursor"
how to program in java
Resources res = getResources();
Drawable img = res.getDrawable(R.drawable.cursor);
Just do it
Drawable img = res.getDrawable(android.R.drawable.cursor);
For API 22 and above have a look at: https://stackoverflow.com/a/29146895/1306012
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With