Styling Data Form Picker selected item text color in Android


#1

Hi, does anyone ever able to change Data Form Picker selected item text color? I have followed the documentation and only able to change the label color textfield text color. Here’s my code:

function dfEditorUpdate(data) {
    if (androidApplication) {
        switch (data.propertyName) {
            case "name":
            case "email":
            case "address":
            case "mobilePhone":
            case "postcode":
                  setLabelColor(data.editor);
                  setTextColor(data.editor);        
                  break;
            case "province":
                  setLabelColor(data.editor);
                  setPickerColor(data.editor);        
                  break;
            case "district":
            case "city":
                  setLabelColor(data.editor);
                  break;
        }
    }
}

function setLabelColor(data) {
    var labelAndroid = data.headerView;
    var color = new Color("white");
    labelAndroid.setTextColor(color.android);
}

function setTextColor(data) {
    var textAndroid = data.getEditorView();
    var color = new Color("white");
    textAndroid.setTextColor(color.android);
}

Thanks.


#2

I’m sorry, could you please be more clear which one works and which one you have issues with?


#3

I have issues with the setPickerColor, others works fine. I forgot to paste the code:

function setPickerColor(data) {
    var labelPickerAndroid = data.getEditorView();
    var color = new Color("white");
    labelPickerAndroid.setTextColor(color.android);
}

#4

Try,

labelPickerAndroid.labelView().setTextColor(color.android);

#5

I will try it and let you know the result. Thanks


#6

I have tried it and i get

TypeError: labelPickerAndroid.labelView is not a function

#7

In that case may be I was wrong in my assumption about which component you were using, can you write a simple playground may with just picker.


#8

Here is the sample code, what i would like to change is the selected picker value text color:

https://play.nativescript.org/?template=play-js&id=bm4ARL&v=22


#9

You can modify colors / layouts by implementing your own Adapter for the editor view (Spinner here), something similar used in NativeScript Dorpdown plugin.

But I’m unsure about exact implementation / not able to debug further as the data form plugin is not open sourced. You might get something if you raise this at nativescript ui feedback repo.


#10

Thanks a lot for the help, i will try to post on github.