Create two layout files:
On the first (asset) have your heading at the top and buttons (Save, Edit, Cancel) at the bottom with a Scrollview (svDetails) filling the rest of the area in the middle.
On the second (assetdetails) have your labels/fields that are on a panel (pnlDetails).
From your activity load them as follows:
Hello Rolf,
Thanks for the code
I tried with this code but it show a page with a scrolling panel. not loaded the layout. here is my code
B4X:
Sub Globals
Dim svDetails As ScrollView
Dim pnlDetails As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
svDetails.Initialize(1000dip)
svDetails.Panel.LoadLayout("assetdetails")
' svDetails.Panel.Height = pnlDetails.Height
End Sub
Here you are.
You must:
- set the Scrollview name in the Designer the same as in the code
- not initialize svDetails in the code
- set svDetails.Panel.Height = pnlDetails.Height
Both of the codes as below ,result is same,they doesn't scrolled.
B4X:
svDetails.Initialize(0)
Activity.AddView(svDetails,0,0,100%x,100%y)
pnlDetails.Initialize("")
svDetails.Panel.AddView(pnlDetails,0,0,svDetails.Width,svDetails.Height)
For i=1 To 11
k= ((70*i)-60)
pnlDetails.AddView(CodeModule.EditTextCreator("EditText"&i),0,k,310dip,60dip)
Next
svDetails.Panel.Height=pnlDetails.Height
or
B4X:
pnlDetails.Initialize("")
Activity.AddView(pnlDetails,0,0,100%x,100%y)
svDetails.Initialize(0)
pnlDetails.AddView(svDetails, 0, 0, pnlDetails.Width,pnlDetails.Height)
For i=1 To 11
k= ((70*i)-60)
svDetails.Panel.AddView(CodeModule.EditTextCreator("EditText"&i),0,k,310dip,60dip)
Next
svDetails.Panel.Height=pnlDetails.Height
svDetails.Initialize(0)
Activity.AddView(svDetails, 0, 0, 100%x, 100%y)
pnlDetails.Initialize("")
svDetails.Panel.AddView(pnlDetails,0,0,svDetails.Width,svDetails.Height)
For i = 0 To 10
k= i * 60dip
pnlDetails.AddView(CodeModule.EditTextCreator("EditText" & (i + 1)), 0, k, 310dip, 60dip)
Next
pnlDetails.Height = i * 60dip
svDetails.Panel.Height=pnlDetails.Height
Second code:
B4X:
pnlDetails.Initialize("")
Activity.AddView(pnlDetails,0,0,100%x,100%y)
svDetails.Initialize(0)
pnlDetails.AddView(svDetails, 0, 0, pnlDetails.Width,pnlDetails.Height)
For i = 0 To 10
k = i * 60dip
svDetails.Panel.AddView(CodeModule.EditTextCreator("EditText" & (i + 1)), 0, k, 310dip, 60dip)
Next
pnlDetails.Height = i * 60dip
svDetails.Panel.Height = pnlDetails.Height
In both codes you missed to set pnlDetails.Height.
In both code the Panel pnlDetails is not useful.
It is usefull in systems1's example because the Panel containing the EditText views is created in the Designer.
I modified a bit the calculation of the Top value, in your calculation you should have used dip values !
I find using the small EditTextCreator routine in a separate module complicated.
You are also missing to set the Tag property to know what EditText view raises any event.
Hi Klaus,
Thank you for make me clearly. I've adjusted all of 3 strategies,shown the same result. But I don't sure to know about manage the EditText view raise any event.
In B4A, the EditText view can raise 3 events:
- EnterPressed
- FocusChanged
- TextChanged
It is possible to add other events to an EditText with the Reflection library like Click, LongClick, Touch etc..
If you don't use any of these events you won't need the Tag propoerty.