Import both R (android.R and <my_package>.R)

93 views Asked by At

I'm using custom background in my app. What i'm looking for is how to get default drawable from android.R. This because if a user select white or dark background, i don't wanna use a custom image, but use for ex: @android:drawable/screen_background_light (so, it doesn't take space to save an image).

If i try to import android.R.* errors occours (that because im using the other file R).

I know how to do it by XML by doing android:background=@android:drawable/screen_background_light" , but this is now what i want to do.

1

There are 1 answers

0
Raghunandan On BEST ANSWER

Do not import android.R.*.

If you want to use the drawable that's in android package use android.R.drawable.screen_background_light

Example: say for button set the btn_plus drawable as background

   Button b = new Button(ActivityName.this);
   b.setBackgroundResource(android.R.drawable.btn_plus);