本文整理匯總了Golang中github.com/nelsam/gxui.Theme.CreateDropDownList方法的典型用法代碼示例。如果您正苦於以下問題:Golang Theme.CreateDropDownList方法的具體用法?Golang Theme.CreateDropDownList怎麽用?Golang Theme.CreateDropDownList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui.Theme
的用法示例。
在下文中一共展示了Theme.CreateDropDownList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: numberPicker
// Number picker uses the gxui.DefaultAdapter for driving a list
func numberPicker(theme gxui.Theme, overlay gxui.BubbleOverlay) gxui.Control {
items := []string{
"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen", "twenty",
}
adapter := gxui.CreateDefaultAdapter()
adapter.SetItems(items)
layout := theme.CreateLinearLayout()
layout.SetDirection(gxui.TopToBottom)
label0 := theme.CreateLabel()
label0.SetText("Numbers:")
layout.AddChild(label0)
dropList := theme.CreateDropDownList()
dropList.SetAdapter(adapter)
dropList.SetBubbleOverlay(overlay)
layout.AddChild(dropList)
list := theme.CreateList()
list.SetAdapter(adapter)
list.SetOrientation(gxui.Vertical)
layout.AddChild(list)
label1 := theme.CreateLabel()
label1.SetMargin(math.Spacing{T: 30})
label1.SetText("Selected number:")
layout.AddChild(label1)
selected := theme.CreateLabel()
layout.AddChild(selected)
dropList.OnSelectionChanged(func(item gxui.AdapterItem) {
if list.Selected() != item {
list.Select(item)
}
})
list.OnSelectionChanged(func(item gxui.AdapterItem) {
if dropList.Selected() != item {
dropList.Select(item)
}
selected.SetText(fmt.Sprintf("%s - %d", item, adapter.ItemIndex(item)))
})
return layout
}