Android comes with lots of system resources (android.R
) that can be used to save you time and make your application lighter.
For example, I recently discovered that Android provides localized strings for Yes (android.R.string.yes
), No (android.R.string.no
), Cancel (android.R.string.cancel
) and Ok (android.R.string.ok
), among other strings.
What other system resources do you recommend using? Or is there a reason to avoid using system resources?
Edit: As noted by Tomas, some of this resources might not produce the results you would expect (particularly, android.R.string.yes/no
returns OK/Cancel
instead of Yes/No
, as reported here). For greater control, you can copy system resources from the Android source code.
System resources areAndroid ids (android.R.id) Android's widgets (android:id/tabs) Color (android.R.color.transparent)
Android applications are broken down into four main components: activities, services, content providers, and broadcast receivers.
You can find a full listing of all system resources in the android package.
Every time I want to do something on Android I check to see if there's a system resource that covers what I want to do. It is helpful to import the Android source code (in particular, their /res/ folder) when searching for already-implemented resources that you might want, so you can see their specific implementation.
Personally, I find myself most often using:
android.R.id
), because you are often required to use these if you want to use some of Android's widgets (for example, TabHost/TabWidget
requires you to use "android:id/tabhost
", "android:id/tabs
" and "android:id/tabcontent
" if you want to implement an XML layout).android.R.color.transparent
.android.R.anim
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With