Rodolfo Paranhos
Rodolfo Paranhos

Reputation: 793

How to change the text input color of "prompt" method in Cordova?

Using navigator.dialogs.prompt method, the typing dialog appears on the screen, but the text is white (same color as background) so the user cannot see what is typing.

I'm using pure Cordova. What to do?

Upvotes: 0

Views: 1840

Answers (3)

totas
totas

Reputation: 10780

You also need to add :

promptInput.setTextColor(0xff888888);

after

promptInput.setHint(defaultText);

Upvotes: 0

John Doherty
John Doherty

Reputation: 4095

As mentioned by @Rodolfo in the comments, the solution:

  1. Open ./platforms/android/src/org/apache/cordova/dialogs/Notification.java
  2. Replace THEME_DEVICE_DEFAULT_LIGHT with THEME_DEVICE_DEFAULT_DARK
  3. Execute cordova platform remove android && cordova platform add android to pick up the changes
  4. Execute cordova build android to rebuild

Upvotes: 1

palucdev
palucdev

Reputation: 316

It's a well known bug. You can try to modify platforms/android/src/org/apache/cordova/dialogs/Notification.java :
search for "public synchronized void prompt"
after " promptInput.setHint(defaultText);" add " promptInput.setHintTextColor(0xff888888);"

Or you can use another version of this plugin, with different theme like: https://github.com/ecorona/cordova-plugin-dialogs-dark

Also you can write your own dialog plugin using Native UI options. There is a fine introduction for begginers at: https://blogs.oracle.com/mobile/entry/introduction_to_custom_cordova_plugin

Upvotes: 1

Related Questions