Kostas_Bar
Member
Hello everyone!
I am building an Android App with B4X for a scanner. In the module, that I'm writing at this moment i want to present some pieces of info about the product scanned to the user. To do that i use TabStrip (because in some cases i need 2 pages for the info and because i like the way it opens the new page and slides). What i need is to close the tabs, every time i scan a new item (TextChanged Event), but i cant find a solution.
Here is my code:
I hope it helps and that someone can give me a solution
I am building an Android App with B4X for a scanner. In the module, that I'm writing at this moment i want to present some pieces of info about the product scanned to the user. To do that i use TabStrip (because in some cases i need 2 pages for the info and because i like the way it opens the new page and slides). What i need is to close the tabs, every time i scan a new item (TextChanged Event), but i cant find a solution.
Here is my code:
text change - create tabs:
Private Sub ScanHereMC_TextChanged (Old As String, New As String)
' I want the existing tabs to be deleted here (if any)
Dim prefix As String
If New.StartsWith("02") Then
prefix = "02"
Else If New.StartsWith("91") Then
prefix = "91"
End If
Dim j As HttpJob
j.Initialize("", Me)
Dim link As String = "The API link here"
Try
Dim url As String = Main.ini.Get("URL")
j.Download(url & link & prefix & "/" & New )
j.GetRequest.SetHeader("Authorization", "Bearer " & token)
wait for (j) jobdone (j As HttpJob)
If j.Success Then
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim jRoot As List = parser.NextArray
Dim jmap As Map = jRoot.Get(0).As(Map)
If prefix = "02" Then
' Two tabs from two Lay files
InfoScroll.LoadLayout("Lay_InfoScroll", "Βασικές Πληροφορίες")
InfoScroll.LoadLayout("Lay_InfoTable", "Ανά Θέση")
InfoTable.AddColumn("ΘΕΣΗ", InfoTable.COLUMN_TYPE_TEXT)
InfoTable.AddColumn("STATUS", InfoTable.COLUMN_TYPE_TEXT)
InfoTable.AddColumn("ΣΥΝΟΛΟ", InfoTable.COLUMN_TYPE_NUMBERS)
Dim dataList As List
dataList.Initialize
LotLbl.Text = "LOT: " & jmap.Get("LOT")
ProvLbl.Text = "Προμηθευτής: " & jmap.Get("ΠΡΟΜΗΘΕΥΤΗΣ")
PerLbl.Text = "Περιγραφή: " & jmap.Get("ΠΕΡΙΓΡΑΦΗ ΕΙΔΟΥΣ")
MeasurLbl.Text = "Μονάδα Μέτρησης: " & jmap.Get("ΜΟΝΑΔΑ ΜΕΤΡΗΣΗΣ")
CodeLbl.Text = "Κωδικός Είδους: " & jmap.Get("ΚΩΔΙΚΟΣ ΕΙΔΟΥΣ")
For Each coljRoot As Map In jRoot
Dim spot As String = coljRoot.Get("ΘΕΣΗ")
Dim status As String = coljRoot.Get("STATUS")
Dim sum As Float = coljRoot.Get("ΣΥΝΟΛΟ")
Dim responseArray As List
responseArray.Initialize()
responseArray = Array( spot, status, sum)
dataList.Add(responseArray.As(List))
Next
InfoTable.SetData(dataList)
Else If prefix = "91" Then
' One tab only here
InfoPanelScroll.AddView(InfoPanelStrip,0,0,InfoScrollPanel.Width, InfoScrollPanel.Height)
InfoScroll.LoadLayout("Lay_InfoScroll", "Βασικές Πληροφορίες")
LotLbl.Text = "LOT: " & jmap.Get("LOT")
ProvLbl.Text = "Προμηθευτής: " & jmap.Get("ΠΡΟΜΗΘΕΥΤΗΣ")
PerLbl.Text = "Περιγραφή: " & jmap.Get("ΠΕΡΙΓΡΑΦΗ ΕΙΔΟΥΣ")
MeasurLbl.Text = "Status: " & jmap.Get("STATUS")
CodeLbl.Text = "Κωδικός Είδους: " & jmap.Get("ΚΩΔΙΚΟΣ ΕΙΔΟΥΣ")
ProdNumLbl.Text = "Αρ. Παρτιδας Παραγωγου: " & jmap.Get("Αρ. Παρτιδας Παραγωγου")
Else
xui.MsgboxAsync("", "ERROR")
End If
End If
j.Release
Catch
Log(LastException)
End Try
If New = "" Then Return
ScanHereMC.Text = ""
ScanHereMC.RequestFocus()
End Sub
I hope it helps and that someone can give me a solution