我正在appcelerator studio中構建自定義模式。如何在DatePicker上設置TextField上的數據
所以這是代碼:
<Alloy>
<Window id="modal_add_edit" onClose="cleanup" modal="true">
<View class="container">
<Label id="title" class="title"/>
<View class="separator"></View>
<TableView id="table" height="Titanium.UI.SIZE" layout="vertical">
<TableViewRow class="menu_item" top="25">
<Label id="description" class="label" left="12" />
<Picker id="comboDecription" left="20" selectionIndicator="true">
<PickerColumn id="column1">
<PickerRow title="Esposizione Tossica"/>
<PickerRow title="Stato civile"/>
<PickerRow title="Diet"/>
</PickerColumn>
</Picker>
</TableViewRow>
<!-- flags -->
<TableViewRow id="data" class="menu_item" top="25">
<!--DATA START-->
<Label id="start_date" class="label" left="12" />
<TextField id="textStartDate" class="field"
width="200px"></TextField>
</TableViewRow>
</TableView>
<View class="separator"></View>
<TableView id="tableButton" width="Titanium.UI.FILL" layout="horizontal">
<TableViewRow class="menu_item" top="25">
<Button id="buttonClose" class="buttonClose" onClick="onClose" ></Button>
<Button id="buttonSave" class="buttonSave"></Button>
</TableViewRow>
</TableView>
</View>
</Window>
</Alloy>
所以我想,如果在textStartdate用戶點擊,則是的DatePicker顯示。這是我的控制器代碼:
var picker = Ti.UI.createPicker({});
$.textStartDate.addEventListener('click', function(e) {
picker.showDatePickerDialog({
value : new Date(), // some date
callback : function(e) {
if (e.cancel) {
Ti.API.info('user canceled dialog');
} else {
selectedDate = e.value;
$.textStartDate.setValue(String.formatDate(selectedDate, 'medium'));
}
}
});
});
然後,如果我嘗試點擊textStartDate,我能看到的DatePicker,然後我設定的數據,點擊OK按鈕,但我不能顯示在textStartDate數據。
如果我能在調試嘗試,代碼:
String.formatDate(selectedDate, 'medium')
返回正確的數據,但我不能看到它在我的EditText
編輯 我添加了屏幕截圖
這是app.tss中的字段類
".field": {
left: "5%",
width: Titanium.UI.FILL,
borderRadius: 5,
hintTextColor: "#aaa",
color: "#333",
backgroundColor: "white"
}
表示字符串,返回正確的字符串,但如果我嘗試設置「pippo」是相同的。文本字段的背景顏色與文本的顏色不同 – bircastri
您可以通過將默認值屬性設置爲任何內容並共享截圖來確認嗎?或只是分享一些代碼,以便我可以在這裏查看 –
好的一刻,我分享屏幕截圖。但如果我嘗試繼續調試,在代碼中設置textStartdate的值之後,如果我嘗試檢查textStartdate的值是正確的,但它不顯示 – bircastri