Is bug?

Jim Brown

Active Member
Licensed User
I am not sure if I am using the Is test correctly but it seems to report certain views under multiple categories:

* Buttons are picked up as 'buttons' and 'labels'
* CheckBoxes are picked up as 'buttons', 'checkboxes', and 'labels'

I have not tested every type of View (in case I am doing something silly here)


TEST
===============
Run example with one view created at a time and observe the log results

B4X:
' Is bug?

Sub Process_Globals
End Sub

Sub Globals
   Dim btn1 As Button
   Dim cb1 As CheckBox
   Dim lb1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   btn1.Initialize("") : btn1.Text="button 1" : Activity.AddView(btn1,5%x,5%y,32%x,8%y)
   'cb1.Initialize("") : cb1.Text="check 1" : Activity.AddView(cb1,5%x,15%y,32%x,8%y)
   'lb1.Initialize("") : lb1.Text="Label 1" : Activity.AddView(lb1,5%x,25%y,32%x,8%y)
End Sub

Sub Activity_Resume
   Dim v As View
   For i=0 To Activity.NumberOfViews-1
      v=Activity.GetView(i)
      If v Is Button Then Log("Button found")
      If v Is CheckBox Then Log("CheckBox found")
      If v Is Label Then Log("Label found")
   Next
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub
 
Last edited:

Jim Brown

Active Member
Licensed User
Ahh. Got you. I guess there no way of telling exactly what 'type' an existing view really is?

What I was attempting to do is get a String name identifying the View:
B4X:
Sub GetViewType(v As View) As String
   If v Is Button Then Return "Button"
   If v Is CheckBox Then Return "CheckBox"
   If v Is EditText Then Return "EditText"
   If v Is ImageView Then Return "ImageView"
   If v Is Label Then Return "Label"
   If v Is ListView Then Return "ListView"
   If v Is Panel Then Return "Panel"
   If v Is ProgressBar Then Return "ProgressBar"
   If v Is RadioButton Then Return "RadioButton"
   If v Is ScrollView Then Return "ScrollView"
   If v Is SeekBar Then Return "SeekBar"
   If v Is Spinner Then Return "Spinner"
   If v Is TabHost Then Return "TabHost"
   If v Is ToggleButton Then Return "ToggleButton"
   If v Is WebView Then Return "WebView"
End Sub
 
Last edited:
Top