0
我已經在這裏閱讀過一篇文章,我們可以交換容器組件。我遵循相同的過程,它爲我工作。當我應用相同的程序服裝列表視圖,我得到 「ReferenceError:無法找到變量:tadawulList」在控制檯上。在BB 10中交換列表視圖的位置級聯
Container {
id:trade
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
topMargin: 10
ListView {
id: tradeList
objectName: "tradeList"
dataModel: _app.dataModel
visible: true;
listItemComponents: [
ListItemComponent {
type: "header"
Header {
title: {
ListItemData
}
}
},
// The tradeList Item
ListItemComponent {
type: "item"
Container {
id:tadawulList
leftPadding: 15.0
rightPadding: 15.0
background: Color.create("#1a1a1a")
preferredHeight: 80.0
topMargin: 6
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Label {
id: symbol
text: ListItemData.Symbol_En
//text: ListItemData.Symbol_En.length()>20?Symbol_En.subString(0,15): Symbol_En
// Text Style and size etc
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.fontSizeValue: 5.0
layoutProperties: StackLayoutProperties {
spaceQuota: 3.0
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
textStyle.color: Color.White
textStyle.fontWeight: FontWeight.Bold
textStyle.fontSize: FontSize.PointValue
// multiline: true
}
Container {
id: tadawulchange1
layout: StackLayout {
}
layoutProperties: StackLayoutProperties {
spaceQuota: 2.0
}
// ListItemData.PerChange.length == 1 ? Color.create("#1a1a1a") :Color.DarkRed
// background: ListItemData.PerChange.indexOf('-') < 0 ?((ListItemData.PerChange.length() == 1) ? Color.create("#1a1a1a") : Color.create("#ff105900")) : ((ListItemData.PerChange.length() == 1) ? Color.create("#1a1a1a") : Color.DarkRed)
background: (ListItemData.PerChange.indexOf('-') < 0)?((ListItemData.PerChange.indexOf('0.00') <0 ? Color.create("#ff105900"): Color.create("#1a1a1a"))): ((ListItemData.PerChange.indexOf('0.00') < 0 ? Color.DarkRed: Color.create("#1a1a1a")))
verticalAlignment: VerticalAlignment.Center
preferredHeight: 20.0
Label {
id: change
text: ListItemData.PerChange
// textStyle.color: ListItemData.PerChange.indexOf('-') < 0 ? Color.Green : Color.Red //here
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.fontSizeValue: 30.0
layoutProperties: StackLayoutProperties {
spaceQuota: 2
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
preferredHeight: 0.0
}
}
Label {
id: ltp
text: ListItemData.LTP
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.fontSizeValue: 30.0
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
textStyle.color: Color.White
textStyle.fontWeight: FontWeight.Default
}
Label {
id: highValue
text: ListItemData.High
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.fontSizeValue: 30.0
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
textStyle.color: Color.White
textStyle.fontWeight: FontWeight.Default
}
Label {
id: lowValue
text: ListItemData.Low
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.fontSizeValue: 30.0
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
textStyle.color: Color.White
textStyle.fontWeight: FontWeight.Default
}
}
}
]
onTriggered: {
var selectedItem = dataModel.data(indexPath);
lightTimer.stop();
_app.dropSymbols(1); // Drop Req for Tadawul
_app.loadQuickWatch(selectedItem.symbol_ID);
}
onVisibleChanged: {
myIndicator.stop();
loader.visible = false
loadText.visible=false
}
}
}
和myButton的點擊如下:
Button {
horizontalAlignment: HorizontalAlignment.Right
imageSource: "asset:///images/search_icon.png"
preferredWidth: 10.0
preferredHeight: 10.0
layoutProperties: StackLayoutProperties {
spaceQuota: 1.0
}
onClicked: {
tadawulList.swap(0, 4);
tadawulList.swap(1, 3);
}
}
請指引我,
謝謝!
哪裏是你的按鈕?它必須位於** ListItemComponent **內部。 –
它位於ListItemComponent(其他容器)的外部,還有其他方法可以實現嗎?當一個按鈕(其他容器)被Cliecked時,我需要交換。 – Sharath
哪個容器的位置要交換按鈕? –