10
votes

How to access android default images ( for example image for seekbar's thumb when is pressed ) from java code ? I am changing thumb but and I copy from platforms/android-12/data/res/drawable-hdpi into my drawable-hdpi folder in project, but it is platform dependent ( color of item, size and so on). Can someone show me how to access this android default item from java code ?

3
Try getting your drawables from android.R.drawable instead of your own R.drawable?Jave

3 Answers

14
votes

Android contains a number of standard resources, such as styles, themes, and layouts. To access these resource, qualify your resource reference with the android package name. For example,

 ImageView img = (ImageView)findViewById(R.id.imgView1);
 img.setImageResource(android.R.drawable.ic_media_play);

Note: but you can only access the resources which are available in android.R packages..'

Look at here android.R

0
votes

In general, in order to access the Android resources using code, you should use android.R.[whatever you want i.e. layout, drawable, etc].

Hope this helps, In case you need any other specific help, please shoot it!

-1
votes

At the end of the article Accessing Resources you can found an answer.