Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i use default android resources in my layout xml?

There are loads of default resources in android. I want to use the android.R.string.cancel and android.R.string.ok.

I can do this in code easily enough

getString(android.R.string.cancel)

but how do do it in the layout.xml

@string/cancel

Tried a few things

@android.R.string/cancel
@android.string/cancel

but these do not work. I'm sure I have seen this on dev tutorials, but can't find it all now.

like image 587
Ne0 Avatar asked Sep 19 '12 09:09

Ne0


People also ask

What are default resources in Android?

Default resources are items that are not specific to any particular device or form factor, and therefore are the default choice by the Android OS if no more specific resources can be found. As such, they're the most common type of resource to create.

Where do I put resources in Android Studio?

Change your resource directory By default, your resources are located in module-name /src/ source-set-name /res/ . For example, resources for your module's main source set are in src/main/res/ and resources for the debug source set are in src/debug/res/ .


1 Answers

It's actually @android:string/cancel

like image 160
Redwarp Avatar answered Sep 22 '22 14:09

Redwarp