(I hope to explain well enough ).
I would like to create items of a CustomListView loading a layout and using its "autoscaled dimensions" at runtime (not for real urgent needs, just to avoid to work on my app, as always ).
To do this, I have decided to create a layout for the item, to load the layout in Activity Main, get the dimensions and create items based on them (dimensions ).
Well, I failed.
Please, see the attached project. It is a little bit confuse because, after the first unsuccess, I tried to use a CallSubDelayed and then I needed two global module variables.
You can see in red the item layout loaded to get its dimensions (in a real project it will be removed).
Also you can see that "selecting" (touching) an item, you will get a log with the item width and the CustomListView width will be set equal to the "wanted item width" (autoscaled dimensions).
I would like to do other considerations (I should write some of this in new threads):
1) I have noticed that if you call a sub using CallSubDelayed from inside Activity_Create, your sub will be executed only after Activity_Resume (I know that Activity_Resume will start immediately after Activity_Create, but I thought...!)
2) I think it is a good practice to use always a panel as base when you create your layout by Designer, as Erel did it here, so you can see if you anchoreted all views well, without being forced to test it selecting devices (top-right of the Designer). You can then set the panel transparent.
3) I forgot it, writing the first two
I would like to create items of a CustomListView loading a layout and using its "autoscaled dimensions" at runtime (not for real urgent needs, just to avoid to work on my app, as always ).
To do this, I have decided to create a layout for the item, to load the layout in Activity Main, get the dimensions and create items based on them (dimensions ).
Well, I failed.
Please, see the attached project. It is a little bit confuse because, after the first unsuccess, I tried to use a CallSubDelayed and then I needed two global module variables.
You can see in red the item layout loaded to get its dimensions (in a real project it will be removed).
Also you can see that "selecting" (touching) an item, you will get a log with the item width and the CustomListView width will be set equal to the "wanted item width" (autoscaled dimensions).
I would like to do other considerations (I should write some of this in new threads):
1) I have noticed that if you call a sub using CallSubDelayed from inside Activity_Create, your sub will be executed only after Activity_Resume (I know that Activity_Resume will start immediately after Activity_Create, but I thought...!)
2) I think it is a good practice to use always a panel as base when you create your layout by Designer, as Erel did it here, so you can see if you anchoreted all views well, without being forced to test it selecting devices (top-right of the Designer). You can then set the panel transparent.
3) I forgot it, writing the first two
Attachments
Last edited: