How to find the correct layout for data fields?

[This might very well be a stupid question, but... I can't find the answer without help :-)]

We like to use layouts for our data fields, and with the way resources can be organised, we can easily provide different layouts for different devices.

But for a specific device - say 920xt - we can actually have three different sizes of data fields depending on the number of fields on the page.

So the question is: how can we decide on which layout to load in onLayout()? Are there some status attribute somewhere we can test? Where might it be then?

Otherwise, we can see two other options, neither of which are optimal
  • we can wait and load the layout at the first call of onUpdate, where we get a DC there we can then deduct the size of the data field. Loading resources
    in the update phase seems like a very bad idea to me - at least it is something you always told to avoid in other UIs.
  • we can load all three layouts from the start and then decide on the layout to use in onUpdate (again based on the DC), call setLayout with the correct
    layout, and last delegate to super. But this will take up additional resources...


What do you say?
  • Former Member
    Former Member over 10 years ago
    Unfortunately, onLayout isn't working properly for data fields right now, so I don't think you will be able to test properly with the 1.0.0 SDK. We hope to have it cleaned up for the next release.

    onLayout gets the same DC that onUpdate gets, so you should be able to select your layout based on that.

    You should get an onLayout call before the next onUpdate call any time the field size changes. In the current simulator implementation that draws all of the fields for a device layout at once, this means onLayout will be getting called a lot, but that won't reflect the device behavior in most cases.