Hello,
Can someone explain to me what is wrong with the performance,
Look:
PrefDialog.PrefItems.Set(0, newItem) ?
java.lang.ClassCastException:
java.lang.String cannot be cast to b4a.example.preferencesdialog
$_b4xprefitem
Used procedures:
template.json
Can someone explain to me what is wrong with the performance,
Look:
PrefDialog.PrefItems.Set(0, newItem) ?
B4X:
...
PrefDialog.Initialize(Parent, "Dialog", 300dip, 400dip)
PrefDialog.LoadFromJson(File.ReadString(File.DirAssets, "template.json"))
...
Dim oldItem As String = PrefDialog.PrefItems.Get(0)
Dim newItem As Object = SFX.MidExtract(oldItem,"Title=","]","Duplicate Record")
PrefDialog.PrefItems.Set(0, newItem) ------------------ >>> ERROR
java.lang.ClassCastException:
java.lang.String cannot be cast to b4a.example.preferencesdialog
$_b4xprefitem
Used procedures:
B4X:
'Used to extract text from a string between to other blocks of text,
'and converted to a new text last parameter function.
Public Sub MidExtract(paramString1 As String, paramString2 As String, paramString3 As String, paramString4 As String) As Object
Private str As String = ""
If (LenString(paramString1) = 0) Then Return ""
If paramString2.Length = 0 And paramString3.Length = 0 Then Return paramString1
If ((paramString1.Contains(paramString2)) And (paramString1.Contains(paramString3))) Then
str = paramString1.Substring2(paramString1.IndexOf(paramString2), paramString1.indexOf(paramString3))
str = str.Substring2(paramString2.Length, str.Length).Trim
str = paramString1.Replace(str, paramString4).Trim
Return str
Else
Return ""
End If
End Sub
'Returns the length of this string.
Public Sub LenString(paramString1 As String) As Int
Return paramString1.Length
End Sub
template.json
B4X:
{
"Version": 1.1,
"Theme": "Light Theme",
"Items": [
{
"title": "Edit Record",
"type": "Separator",
"key": "",
"required": false
},
{
"title": "First Name",
"type": "Text",
"key": "FirstName",
"required": true
},
{
"title": "Last Name",
"type": "Text",
"key": "LastName",
"required": true
},
{
"title": "Company",
"type": "Text",
"key": "Company",
"required": true
},
{
"title": "Address",
"type": "Text",
"key": "Address",
"required": true
},
{
"title": "Email",
"type": "Text",
"key": "Email",
"required": true
}
]
}
Last edited: