Witek
Witek

Reputation: 6462

How to reference Android holo resources from code?

How do I reference Android holo resources within Java code? Like the blue colors or drawables? It seams these are not available in android.R...

Upvotes: 2

Views: 850

Answers (2)

Neron T
Neron T

Reputation: 369

You can also just "copy" the style and modify the parts you don't like, i.e.:

<style name="StyledIndicators" parent="@android:style/Theme.Light">
    <item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>  
</style>

more examples

Upvotes: 0

Zhar
Zhar

Reputation: 3530

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 (see original source here).

Here is an exemple for image :

ImageView imageView = (ImageView) findViewById(R.id.myimageview); imageView.setImageResource(android.R.drawable.ic_media_play);

If the import android.R cannot be found, you should check your project properties and set the right platform sdk. From Eclipse, right click on project > properties > android and choose the corresponding "project build target".

Upvotes: 3

Related Questions