Android Question Custom view dimensions, if variable height

peacemaker

Expert
Licensed User
Longtime User
HI, All

What are the common rules for creating new custom visual views ?
Expecially, if the view should have some component with the variable height - say some custom list view, where the lines qty is unknown yet when the view overall size should be created.
If the each line height should be calcualted according to its text length and already fixed width - the overall view height should be calculated only at the very final.
And if some lines (say, 1....7), the overall view height should be < 100%y, so the view hight must not be fixed during creation.

1580885421217.png


For using StringUtils.MeasureMultilineTextHeight(label, label.text) - this label must be already added on some container, but inside the view - no container is created yet...

How to be ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
So, if i would like to make a custom view based on B4XDialog + B4XListTemplate - how the class should be initialized ?
I mean when the container panel is got ?

B4X dialog is initialized in the activity, but how if it is inside the class ? And no layout is needed, all only be the runtime code.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Pass Activity to the class.

So, for view class that must return a result code the initialization must be done with passing Activity (or panel to have the view container) and some
mCallbackModule As Object (the same activity) to make callback ?Are these not the same single variable ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel.
And finally: each B4X dialog requires "Activity_KeyPress" sub in each Activity. The modal popup menu lib does not require it.
Is it impossible to handle it inside the class ?
 

Attachments

  • PopUpTextMenu_project_0.15.zip
    13.2 KB · Views: 89
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are many mistakes in this project. Why are you using an old version of CustomListView?
Use xCustomListView class.

Your approach with this class is wrong. It will only make it more complicated to use the dialog. Don't wrap B4XDialog.
Use it directly.
If you are implementing a new layout (which is not the case here) then you should build a new template class.
 
Upvote 0
Top