I just created my own custom TimePickerDialog (implemented skipping and other things) and I'm wondering how I can use the same title as in the original TimePickerDialog "Select date". I could hardcode it, as the people downloading this app will only be norwegian, but it will be inconsistent for users with english language set in their phones (the DatePicker has english text, the TimePicker has norwegian...).
I looked at android.R.strings, but i could only find very basic strings like "cancel", "yes", "no" etc... is there anyway to get the default localized title for DateDialog, or other dialogs for that matter?
There are some default strings available in android.R.string
. You can get them like this:
String no = yourContext.getString(android.R.string.no);
You need to define your own values in a strings.xml file (doc: http://developer.android.com/guide/topics/resources/string-resource.html).
For example, you could declare in res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="select_date">Select Date</string>
</resources>
Then, in your layout, you need to use this value via @string/select_date
If you want your app to support several languages, you have to add additionnal strings.xml files that will be located in res/values-[the language]/strings.xml
So for example, in order to support french, you would have in res/values-fr/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="select_date">Choisissez une date</string>
</resources>
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