Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get system icon programmatically

Tags:

android

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);
like image 611
Ankita Bansal Avatar asked May 08 '15 07:05

Ankita Bansal


1 Answers

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

like image 160
M D Avatar answered Oct 11 '22 13:10

M D