【问题标题】:Titanium picker in Android always white text colorAndroid中的钛选择器始终为白色文本颜色
【发布时间】:2014-07-28 12:53:42
【问题描述】:

我正在为 Titanium 中的 Android 应用构建搜索系统。其中一个选项是您可以使用选择器选择一个区域。

但是当您选择一个区域时,文本始终是白色的,我无法将其变为黑色。这是我的代码。

搜索.js

var args = arguments[0] || {};
var apiHelper = require('apiHelper');
var that = this;
//$.ind.message = 'Ophalen van huidige locatie';
//$.ind.show();
$.ind.hide();
// REQUIRE THE HEADER BAR FROM headerBar controller
// we will pass our Home View so we can animate it when we click the menu button
var headerBar = Alloy.createController("adrHeaderBar", {
    parentView : $.winSearch,
    title : args.menuItem.title,
    isFlyout : args.isFlyout
}).getView();

$.winSearch.add(headerBar);

// Get Locations
var db = Ti.Database.open('DriveEatSleep');
var jsonRS = db.execute('SELECT * FROM locations');
var data = [];  
var i = 1;
data[0]=Titanium.UI.createPickerRow({title:"Selecteer streek/land"});
while (jsonRS.isValidRow())
{
data[i]=Titanium.UI.createPickerRow({title:jsonRS.fieldByName('name')});
i = i + 1;
jsonRS.next();
}
 db.close();
$.Area.add(data);
$.Area.setSelectedRow(0,1, false);

搜索.tss

"#Area":{
left : '14dp',
    right : '14dp',
    width : Ti.UI.FILL,
    font: {
        fontFamily:'Arial',
        fontSize: '14dp',
        fontStyle: 'normal',
        fontWeight: 'normal',
        fontcolor:'black'
  },
    paddingLeft : '10dp',
    top:"15dp",
    borderWidth : '1dp',
    borderColor: "#000",
    backgroundColor:"#FFF",
    color:"#000"
}
"#areaView":{
    color:"#000"
}

还有search.xml

<Alloy>

    <View id="winSearch">
    <ScrollView id='searchScroll'>
        <Label id='lblText'>Zoek op naam, plaats of adres</Label>

        <TextField id='txtName'></TextField>
        <Label id='lblOf'>OF</Label>
        <View id='areaView'>
        <Picker id='Area' selectionIndicator="true">

        </Picker>
        </View>

    </ScrollView>
    <ActivityIndicator id="ind" message="Ophalen van locatie...">
        </ActivityIndicator>
    </View>
</Alloy>

例如出了什么问题

【问题讨论】:

标签: android titanium picker


【解决方案1】:

Picker 没有font 属性,并且颜色不是通过font 对象设置的,而是通过color 属性设置的(Picker 也没有)。

您需要在 PickerRows 中添加 Label 和所需的 fontcolor

data[i] = Titanium.UI.createPickerRow({
    layout: 'vertical'
});

data[i].add(Titanium.UI.createLabel({
    left: 0,
    text: jsonRS.fieldByName('name'),
    color: 'black',
    font: {
        fontFamily:'Arial',
        fontSize: '14dp',
        fontStyle: 'normal',
        fontWeight: 'normal'
    }
}));

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-14
  • 1970-01-01
  • 2017-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-12
相关资源
最近更新 更多