As a newbie I am not able to overcome the problem described as follows:
Task
I want to access all Edittexts of a view via a list, so that I can easily cycle through them for different testing purposes.
For this, I have created a list in Sub Globals of the corresponding activity. To retrieve a single item of the list, I use a temporary variable of type EditText, and assign the item with its index via the Get-Method. (This should be equivalent to the DirectCast of VisualBasic.)
Unfortunately, at this line the java compiler throws the following error:
java.lang.ClassCastException: anywheresoftware.b4a.objects.EditTextWrapper cannot be cast to android.widget.EditText
Here is now my code. The lines in Activity_Create are for testing purposes to show the error. The error is thrown on the line w = Inputs.Get(0):
Any help is very much appreciated. Many thanks in advance.
LittleAlf
Task
I want to access all Edittexts of a view via a list, so that I can easily cycle through them for different testing purposes.
For this, I have created a list in Sub Globals of the corresponding activity. To retrieve a single item of the list, I use a temporary variable of type EditText, and assign the item with its index via the Get-Method. (This should be equivalent to the DirectCast of VisualBasic.)
Unfortunately, at this line the java compiler throws the following error:
java.lang.ClassCastException: anywheresoftware.b4a.objects.EditTextWrapper cannot be cast to android.widget.EditText
Here is now my code. The lines in Activity_Create are for testing purposes to show the error. The error is thrown on the line w = Inputs.Get(0):
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim tbxVolumeFlow As EditText
Dim tbxAltitude As EditText
Dim tbxPressure As EditText
Dim tbxTemperature As EditText
Dim Inputs As List
Inputs.initialize
Inputs.AddAll(Array As EditText(tbxVolumeFlow, tbxAltitude, tbxPressure, tbxTemperature))
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim w As EditText
Msgbox( Inputs.Size,"")
w=Inputs.Get(0)
Msgbox( w.text,"")
End Sub
Any help is very much appreciated. Many thanks in advance.
LittleAlf