Android Question [newbie] List, imageview, initialization and more

pierrem

Member
Licensed User
Longtime User
Hi there,

Just new to B4A, I've started tosearch and read the manual but ...

The code :

Sub Globals
Dim images As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout1") ' layout1 contents 'img1.jpg'

For cpt=0 To 2
Dim img As ImageView
img.Initialize("")
img.Bitmap=LoadBitmap(File.DirAssets,"img1.jpg")
'img.Left=100*cpt
img.Top=100
images.Add(img)
Next

For cpt=0 To images.Size-1
Log(images.Get(cpt).Left)
Next
End Sub

The questions & things I misunderstand :

1°) How to Initialize an ImageView ?
if obj.Initialize("") enough ?
Not clearly found in the docs ... (and how to know how initialize other object ?)

2°) It seems that img is not an ImageView object, as I can't assigne Left and Top properties.
If tried (img.Top = 100) raises an error (null object)
Should be a bad initialization, cf n°1 !

3°) How to read the property Left as in : (images.Get(cpt).Left
BTW, images.Get(x).Bitmap also raises an error ... but not the assignation in 1st loop

B4A seems to be a great product ... but hard to start
:)

Thks in advance,
and sorry if these questions seem stupid.
 
Last edited:

pierrem

Member
Licensed User
Longtime User
Klaus,

Thanks for this quick answer ...
I upload the 'project' ... written only to (try to) learn, absolutely no interrest at all !
:)
 

Attachments

  • test-01.zip
    79.6 KB · Views: 216
Upvote 0

pierrem

Member
Licensed User
Longtime User
Klaus,

The layout is only to load image ...
What I want to try :
create a list of imageview
fill 3 elements with an image and set propreties
read and log properties
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The layout will not load the images.
Declaring the image files in the Designer only attaches the filenames to the project.
You can add the ImageViews either in the Designer or in the code.
In the Designer you can add the image files to the ImageViews, these will be automatically shown when the layout is loaded.
If you add the ImageViews in the code you beed to initialize them, add them to the activity or a panel and load the image files.

You should read the Beginner's Guide to get the basics of Android and B4A.
You could have a look at :
- ScrollView example
- ImageScrollView
 
Upvote 0
Top