'i have a question about class and list and many view ,
'What to deal with is , many EditText placed on form ,
'if the value(text) of any EditText is changed then the backcolor of it will be changed ,
'i used class module in vb , it can fulfil the task , the following is code
the followring code is in form1 ,
the followring code is in class1 ,
' 一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
' in b4a , i do not know how to this , so ,i read some sample code , and i write some code ,such as following ,
' i do not know how to trigger sub edittext_in_class_TextChanged in class , so ,i write following to try ,
' For i = 0 To L_1_LIST_1.Size - 1
'
' CallSub(L_1_LIST_1.Get(i), "edittext_in_class_TextChanged")
' Next
' but , tip is layer not available ,
' of course ,EditText1 EditText1 EditText3 is not changed , failed to be changed ,
' 一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
the following is code in main activity ,
the following is code in c_l_value_change ,wihich is a standard calss module,
i do not know how to do ,so i post the code ,
thank you ,
'What to deal with is , many EditText placed on form ,
'if the value(text) of any EditText is changed then the backcolor of it will be changed ,
'i used class module in vb , it can fulfil the task , the following is code
the followring code is in form1 ,
B4X:
' code in form1 of vb ,
'
Private collec_1 As New Collection
Private Sub Form_Initialize()
''┌一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一┐
Set cla_1 = New Class1: Set cla_1.butt_of_class = Form1.Cmd_1: collec_1.Add cla_1 '
Set cla_1 = New Class1: Set cla_1.butt_of_class = Form1.Cmd_2: collec_1.Add cla_1
Set cla_1 = New Class1: Set cla_1.butt_of_class = Form1.Cmd_3: collec_1.Add cla_1
''└一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一┘
'┌一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一┐
Set cla_1 = New Class1: Set cla_1.TEXT_of_class = Form1.Text1: collec_1.Add cla_1
Set cla_1 = New Class1: Set cla_1.TEXT_of_class = Form1.Text2: collec_1.Add cla_1
Set cla_1 = New Class1: Set cla_1.TEXT_of_class = Form1.Text3: collec_1.Add cla_1
'└一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一┘
Me.WindowState = 2
End Sub
the followring code is in class1 ,
B4X:
Public WithEvents butt_of_class As CommandButton '
Public WithEvents TEXT_of_class As TextBox
Public v_numbers_of_times As Integer
'
Private Sub TEXT_of_class_Change()
v_numbers_of_times = v_numbers_of_times + 1
If v_numbers_of_times Mod 2 = 0 Then TEXT_of_class.BackColor = vbRed
If v_numbers_of_times Mod 2 = 1 Then TEXT_of_class.BackColor = vbBlue
End Sub
' 一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
' in b4a , i do not know how to this , so ,i read some sample code , and i write some code ,such as following ,
' i do not know how to trigger sub edittext_in_class_TextChanged in class , so ,i write following to try ,
' For i = 0 To L_1_LIST_1.Size - 1
'
' CallSub(L_1_LIST_1.Get(i), "edittext_in_class_TextChanged")
' Next
' but , tip is layer not available ,
' of course ,EditText1 EditText1 EditText3 is not changed , failed to be changed ,
' 一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
the following is code in main activity ,
B4X:
Sub Globals
Private EditText1 As EditText
Private EditText2 As EditText
Private EditText3 As EditText
' Private Button1 As Button
Public L_1_LIST_1 As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
L_1_LIST_1.Initialize
Dim cla_1 As c_l_value_change
cla_1.Initialize(L_1_LIST_1 , 1, 11, EditText1)
'一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
Dim cla_2 As c_l_value_change
cla_2.Initialize(L_1_LIST_1 , 2, 22, EditText2)
'一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
Dim cla_3 As c_l_value_change
cla_3.Initialize(L_1_LIST_1 , 3, 33, EditText3)
'一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一
' i do not know how to trigger edittext_in_class_TextChanged in class , so ,i write following to try ,
' but , tip is layer not available ,
Private i As Int
For i = 0 To L_1_LIST_1.Size - 1
CallSub(L_1_LIST_1.Get(i), "edittext_in_class_TextChanged")
Next
'' Activity.Invalidate
' : cla_1.Old=1: cla_1.new = 3: cla_1.edittext_in_class = EditText1: L_1_LIST_1.Add(cla_1): cla_1.edittext_in_class_TextChanged
' cla_1.Old=1: cla_1.new = 3: cla_2.edittext_in_class = EditText2 : L_1_LIST_1.Add(cla_1)
' cla_1.Old=1: cla_1.new = 3: cla_3.edittext_in_class = EditText1:L_1_LIST_1.Add(cla_3)
End Sub
the following is code in c_l_value_change ,wihich is a standard calss module,
B4X:
#Event: TextChanged
#Event: click
#Event: edittext_in_class_TextChanged
#Event: _click
Sub Class_Globals
Public New_in_class, Old_in_class As Int
Public edittext_in_class As EditText
End Sub
Sub Initialize (L_1_LIST_1 As List, Old As Int, New As Int, view_1 As View)
L_1_LIST_1.Add(Me) '
New_in_class = New
edittext_in_class.Initialize("TextChanged")
End Sub
Sub edittext_in_class_TextChanged
edittext_in_class.text = New_in_class
End Sub
i do not know how to do ,so i post the code ,
thank you ,