Android Question B4X Declarations

My original question: The designer window in generation calls all items B4XView. Fine, but how does the program know its dealing with a combobox? Do I change its name to B4XComboBox in the declaration (in Sub Class Globals) or is there some other way of declaring an item a combobox?

Errol replied: " That's not true. It will never set the type of custom views to B4XView. For further discussion please start a new thread. "

Hi Errol

This is a copy & Paste from my B4J IDE


Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private btnClear As B4XView
Private btnSave As B4XView
Private cboCustomer As B4XView
Private cboItems As B4XView
Private cboMeasure As B4XView
Private DatePicker As B4XView
Private edtAmount As B4XView
Private edtInvoice As B4XView
Private edtQty As B4XView
Private lbl As B4XView
Private lblAmount As B4XView
Private lblCustomer As B4XView
Private lblInvoice As B4XView
Private lblItem As B4XView
Private lblMeasure As B4XView
Private lblQty As B4XView
Private Pane1 As B4XView
Public sDate As String
Public sCustomer As String
Public sInvoice As String
Public sQty As String
Public sMsre As String
Public sItem As String
Public iAmt As Double
Public sfile As String
Public fileHandle As String

End Sub

Not sure what you meant, or maybe it's just something I'm doing wrong in the designer window, but that is the declaration generated by the designer window. As you can see they're all called B4XViews? I am definitely doing something out of the ordinary then?

Regards

David
 

LucaMs

Expert
Licensed User
Longtime User
Ooooh, I think I know where I went wrong. I shouldn't tic the box labelled "B4XView"?
If you are developing cross-platform software, you should set the "B4XView" Checkbox, so that the Designer declares the views as B4XView, as you did.

Then, in the source code, when you need to use specific methods and/or properties, "cast" the B4XView, possibly conditioning the lines according to the language (#IF B4A.... #IF B4J...)
B4X:
cboCustomer.As(ComboBox).SelectedIndex = 5

Obviously you can also do the opposite, but precisely in a cross-platform project it is not the right choice.
B4X:
Dim cboCustomer As ComboBox
    
cboCustomer.As(B4XView).Enabled = False
 
Upvote 0
Top