Hi,
Is there a way to change the width of an Inputlist? I want to prevent twoliners.
Kind regards,
André
Is there a way to change the width of an Inputlist? I want to prevent twoliners.
Kind regards,
André
The B4XDialog (XUI Views library) with a B4XListTemplate (mentioned by @zed ) is a good alternative.Msgbox and other modal dialogs are deprecated. Use the async methods instead. (warning #34)
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public keuzedialog As B4XDialog
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Private Sub Button1_Click
keuzedialog.Initialize(Root)
keuzedialog.PutAtTop = True
keuzedialog.BackgroundColor = Colors.White
Dim width As Int =...
Hi,Can you show some code where you use an "Inputlist"?
Which variable type do you refer to with "Inputlist'"?
If you ask the right question then you might get the answer you are looking for...
Dim Keuze(Cursor1.RowCount) As String
Dim Nummer(Cursor1.RowCount) As String
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
Keuze(i)=Cursor1.GetString("ProjectID")&" - "&Cursor1.GetString("Naam")
Nummer(i)=Cursor1.GetString("ProjectID")
Next
ProgressDialogHide
Dim Ret As Int
Ret = InputList(Keuze,"Projecten",-1)
If Ret = DialogResponse.CANCEL Then
ToastMessageShow("Afgebroken", False)
CurrentProjectID = ""
Else
CurrentProjectID = Nummer(Ret)
End If
What is inputlist?
You mean that "Keuze" is not displayed on a single line because the string is too long?
I don't understand your question.
The B4XDialog (XUI Views library) with a B4XListTemplate (mentioned by @zed ) is a good alternative.Msgbox and other modal dialogs are deprecated. Use the async methods instead. (warning #34)
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public keuzedialog As B4XDialog
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Private Sub Button1_Click
keuzedialog.Initialize(Root)
keuzedialog.PutAtTop = True
keuzedialog.BackgroundColor = Colors.White
Dim width As Int = GetDeviceLayoutValues.Width - 10dip
Dim height As Int = GetDeviceLayoutValues.Height - 100dip
Dim keuzelst As List
keuzelst.Initialize
keuzelst.Add("id1 - een heel lange tekst voor de eerste keuze die normaal gezien niet op 1 regel kan.")
keuzelst.Add("id2 - een korte tekst")
keuzelst.Add("id3 - een redelijk korte naam")
Dim listtpl As B4XListTemplate
listtpl.Initialize
listtpl.Resize(width,height)
listtpl.Options = keuzelst
listtpl.CustomListView1.AsView.SetLayoutAnimated(0, 0dip, 0dip, width - 10dip, height)
listtpl.CustomListView1.sv.SetLayoutAnimated(0, 0dip, 0dip, width - 10dip, height)
listtpl.CustomListView1.DefaultTextBackgroundColor = xui.Color_White
listtpl.CustomListView1.DefaultTextColor = xui.Color_Black
keuzedialog.ButtonsHeight = 50dip ' set to 1dip to force the user to select
Wait For (keuzedialog.ShowTemplate(listtpl, "", "", "Cancel")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
xui.MsgboxAsync(listtpl.SelectedItem,"Selected item")
End If
End Sub
Private Sub Button1_Click
keuzedialog.Initialize(Root)
keuzedialog.PutAtTop = True
keuzedialog.BackgroundColor = Colors.White
Dim width As Int = GetDeviceLayoutValues.Width - 10dip
Dim height As Int = GetDeviceLayoutValues.Height - 100dip
Dim keuzelst As List
keuzelst.Initialize
keuzelst.Add("id1 - een heel lange tekst voor de eerste keuze die normaal gezien niet op 1 regel kan.")
keuzelst.Add("id2 - een korte tekst")
keuzelst.Add("id3 - een redelijk korte naam")
Dim pnl As B4XView = xui.CreatePanel("")
pnl.SetLayoutAnimated(0dip, 0dip, 0dip,width - 10dip, height)
pnl.LoadLayout("keuzedialog_layout")
fill_clv1
Dim rsub1 As ResumableSub = keuzedialog.ShowCustom(pnl, "OK", "", "")
Wait For (rsub1) Complete (Result As Int)
If Result = xui.dialogResponse_Positive Then
'
End If
End Sub
Private Sub fill_clv1
For i = 0 To keuze.Length -1
Dim pnl As Panel = clv1_item(keuze(i))
clv1.Add(pnl,i)
Next
End Sub
Private Sub clv1_item(naam As String) As Panel
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0dip, 0dip, clv1.AsView.Width,40dip)
p.LoadLayout("clv1item_layout")
lblnaam.Text = naam
Return p
End Sub
Private Sub clv1_ItemClick (Index As Int, Value As Object)
Log(clv1.GetValue(Index))
clv1.GetPanel(Index).GetView(0).Color = xui.Color_Green
End Sub
The InputList function in B4A is deprecated.
The B4XDialog (XUI Views library) with a B4XListTemplate (mentioned by @zed ) is a good alternative.
Some sample code:
View attachment 157328B4XDialog with B4XListTemplate:Sub Class_Globals Private Root As B4XView Private xui As XUI Public keuzedialog As B4XDialog End Sub Public Sub Initialize B4XPages.GetManager.LogEvents = True End Sub Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("MainPage") End Sub Private Sub Button1_Click keuzedialog.Initialize(Root) keuzedialog.PutAtTop = True keuzedialog.BackgroundColor = Colors.White Dim width As Int = GetDeviceLayoutValues.Width - 10dip Dim height As Int = GetDeviceLayoutValues.Height - 100dip Dim keuzelst As List keuzelst.Initialize keuzelst.Add("id1 - een heel lange tekst voor de eerste keuze die normaal gezien niet op 1 regel kan.") keuzelst.Add("id2 - een korte tekst") keuzelst.Add("id3 - een redelijk korte naam") Dim listtpl As B4XListTemplate listtpl.Initialize listtpl.Resize(width,height) listtpl.Options = keuzelst listtpl.CustomListView1.AsView.SetLayoutAnimated(0, 0dip, 0dip, width - 10dip, height) listtpl.CustomListView1.sv.SetLayoutAnimated(0, 0dip, 0dip, width - 10dip, height) listtpl.CustomListView1.DefaultTextBackgroundColor = xui.Color_White listtpl.CustomListView1.DefaultTextColor = xui.Color_Black keuzedialog.ButtonsHeight = 50dip ' set to 1dip to force the user to select Wait For (keuzedialog.ShowTemplate(listtpl, "", "", "Cancel")) Complete (Result As Int) If Result = xui.DialogResponse_Positive Then xui.MsgboxAsync(listtpl.SelectedItem,"Selected item") End If End Sub
But as you can see the first line is still longer than one line. The CustomListView from the template uses text items.
Another way to use a list is to use a B4XDialog with a custom layout.
View attachment 157329B4XDialog with custom layout:Private Sub Button1_Click keuzedialog.Initialize(Root) keuzedialog.PutAtTop = True keuzedialog.BackgroundColor = Colors.White Dim width As Int = GetDeviceLayoutValues.Width - 10dip Dim height As Int = GetDeviceLayoutValues.Height - 100dip Dim keuzelst As List keuzelst.Initialize keuzelst.Add("id1 - een heel lange tekst voor de eerste keuze die normaal gezien niet op 1 regel kan.") keuzelst.Add("id2 - een korte tekst") keuzelst.Add("id3 - een redelijk korte naam") Dim pnl As B4XView = xui.CreatePanel("") pnl.SetLayoutAnimated(0dip, 0dip, 0dip,width - 10dip, height) pnl.LoadLayout("keuzedialog_layout") fill_clv1 Dim rsub1 As ResumableSub = keuzedialog.ShowCustom(pnl, "OK", "", "") Wait For (rsub1) Complete (Result As Int) If Result = xui.dialogResponse_Positive Then ' End If End Sub Private Sub fill_clv1 For i = 0 To keuze.Length -1 Dim pnl As Panel = clv1_item(keuze(i)) clv1.Add(pnl,i) Next End Sub Private Sub clv1_item(naam As String) As Panel Dim p As B4XView = xui.CreatePanel("") p.SetLayoutAnimated(0, 0dip, 0dip, clv1.AsView.Width,40dip) p.LoadLayout("clv1item_layout") lblnaam.Text = naam Return p End Sub Private Sub clv1_ItemClick (Index As Int, Value As Object) Log(clv1.GetValue(Index)) clv1.GetPanel(Index).GetView(0).Color = xui.Color_Green End Sub
In the custom layout (clv1item_layout) the lblnaam label Single Line property is checked. This causes the text to be truncated.
You can also use a B4XComboBox that also has a Single Line property you can check.
View attachment 157330
Or you can use a Spinner.
View attachment 157331
To answer your question: i don't think it is possible to set the items from an InputList to a single line (no wrapping).