J'ai lu un article ici que http://bbcascadescode.tumblr.com/post/51115772119/swap-function-in-containers, nous pouvons échanger les composants du conteneur.J'ai suivi la même procédure et cela fonctionne pour moi. Quand j'ai appliqué la même procédure pour Costume Listview, je reçois "ReferenceError: Impossible de trouver la variable: tadawulList" sur la console.Swaping Listview positions dans BB 10 Cascades
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
}
}
}
et myButton Cliquez comme suit:
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);
}
}
S'il vous plaît me guide,
Merci !!!
Où est le bouton? il doit être à l'intérieur ** ListItemComponent ** .. –
Il est en dehors du ListItemComponent (autre conteneur), Y at-il un autre moyen d'y parvenir? J'ai besoin d'échanger quand un bouton (autre conteneur) est cliecked. – Sharath
quelle position du conteneur que vous voulez échanger sur le bouton ?? –