-
Notifications
You must be signed in to change notification settings - Fork 64
Add localized key names
Keval edited this page Apr 13, 2017
·
7 revisions
- Nowadays most of the application uses localized strings and resources to provide more customized experience to their users.
- PassCodeView supports localization of the title and key names.
- You can set the custom names of the keys by using
KeyNamesBuilder
. - This class uses builder pattern. You can set the name of each individual number key.
- This is an optional parameter. If this parameter is not set library will display key names in default English locale.
- Create the string resources for each key name and for each locale you want to support.
- You can set each individual key name using
KeyNamesBuilder
in your activity/fragment java file.
//Override the string resources for each key for different locales.
KeyNamesBuilder keyNamesBuilder = new KeyNamesBuilder(this)
.setKeyOne(R.string.key_1) //The name you want to display on key with digit value 1.
.setKeyTwo(R.string.key_2) //The name you want to display on key with digit value 2.
.setKeyThree(R.string.key_3) //...
.setKeyFour(R.string.key_4) //...
.setKeyFive(R.string.key_5)
.setKeySix(R.string.key_6)
.setKeySeven(R.string.key_7)
.setKeyEight(R.string.key_8)
.setKeyNine(R.string.key_9)
.setKeyZero(R.string.key_0);
- Set the key names in
PINView
.
PinView pinView = (PinView) findViewById(R.id.pin_view);
//Set the name of the keys based on your locale.
//OPTIONAL. If not passed key names will be displayed based on English locale.
pinView.setKeyNames(keyNamesBuilder);
- That's it! For more info, you can see sample project which supports 4 different locales.
- By default each key name is set to English locale. So, if you don't set the name of any key
KeyNamesBuilder
, it will be displayed in English locale.
English | Hindi |
---|---|