Titanium 创建自定义选择器控件
请参见自定义选择器的屏幕截图:Titanium 创建自定义选择器控件,titanium,appcelerator,titanium-mobile,appcelerator-mobile,picker,Titanium,Appcelerator,Titanium Mobile,Appcelerator Mobile,Picker,请参见自定义选择器的屏幕截图: 我知道没有办法用钛合金来设计选择器控制。此选择器只需在iOS iPad上工作。我想我可以破解TableView控件来代替选择器来实现所需的样式。这合理吗?如何捕捉TableViewRows,使其始终处于中心位置,就像典型的拾取控件中所看到的那样?这是一个困难的问题,我想说的是,您只需要视图和标签,以及如果有人上下滑动并仅更改标签,您可以识别的滑动事件。您可以使用回调函数来实现这一点,我希望这段代码能够帮助您我们已经用这段代码创建了一个自定义选择器 使用合金 XML
我知道没有办法用钛合金来设计选择器控制。此选择器只需在iOS iPad上工作。我想我可以破解TableView控件来代替选择器来实现所需的样式。这合理吗?如何捕捉TableViewRows,使其始终处于中心位置,就像典型的拾取控件中所看到的那样?这是一个困难的问题,我想说的是,您只需要视图和标签,以及如果有人上下滑动并仅更改标签,您可以识别的滑动事件。您可以使用回调函数来实现这一点,我希望这段代码能够帮助您我们已经用这段代码创建了一个自定义选择器 使用合金 XML JS
<View id="numOfIntrusionsPickerContainer" class="compositeWrapperPicker noMargins" >
<View id="numOfIntrusionsButtonContainer" class="horizontalWrapper"></View>
".compositeWrapperPicker" : {
height: Ti.UI.SIZE,
layout: "composite",
width:Ti.UI.SIZE
},
".horizontalWrapper" : {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
layout: "horizontal"
},
// INSTANTIATION
var args = arguments[0] || {};
var widthValue = 120;
var pickerEnabled = true;
if(args.width != null){
widthValue = args.width;
}
if(args.isEnabled != null){
pickerEnabled = args.isEnabled;
}
// STYLING
// ADDITIONS
// pressed arg can be: true,false,null. false & null are equal
// true = 'yes' is Pressed at creation, false/null = 'no' is pressed
var btn_main = Ti.UI.createButton({
top: 5,
bottom: 0,
left:0,
right:5,
height: 45,
enabled: pickerEnabled,
width: widthValue,
borderRadius: 5,
backgroundImage: "/images/bttn_gray_flex.png",
backgroundSelectedImage : "/images/bttn_gray_press_flex.png",
backgroundFocusedImage : "/images/bttn_gray_press_flex.png"
});
var picker_divider = Ti.UI.createImageView({
right: 43,
bottom:2,
touchEnable:false,
focusable:false,
image: "/images/Divider_picker.png"
});
var picker_arrows = Ti.UI.createImageView({
right: 16,
top: 17,
touchEnabled: false,
focusable: false,
image: "/images/bttn_selector_arrow.png"
});
$.pickerContainer.add(btn_main);
$.pickerContainer.add(picker_divider);
$.pickerContainer.add(picker_arrows);
// CODE
// LISTENERS
if(args.callBack != null){
btn_main.addEventListener("click",function(_event){
args.callBack(_event);
});
}