I am working in a project in which user fills a questionnaire and the answers are then submitt开发者_运维百科ed to the server. For simplicity I have just kept two questions per screen and after clicking on the next command the user gets next two questions. I have used lwuit framework in this project.
To reduce the memory requirements I create form
, questLabel1
, ansCombo1
,questLabel2
and ansCombo2
only once. and their properties are set as per the current frame (screen). The problem is if you are in form 2 and you scroll down to the last option and then you click the next button, since you scrolled down the form doesn't displays the upper components even on the next form tried so many thing. creating a new instance of the form may work but I don't want to use that, for obvious memory reasons,
Any other solution?
thanks in advance,
To make it scroll so that component is visible, check Component
/Container
API javadocs. I've seen at lwuit page these suggest some methods with semantics that fits - scrollComponentToVisible
, scrollRectToVisible
. "Makes sure the component is visible in the scroll if this container is scrollable..." stuff like that
// above extracted from comment to an answer to make it more visible
// for the case if some reader has similar problem
Have you tried form.revalidate()
?. Because this is useful when you modify the container hierarchy and need to redo the layout.
Update: Use requestFocus();
on first component of next form. Its automatically focused on first (Upper) component.
You can use form.refreshTheme() or form.revalidate() for refreshing your form. If you have made updates on any particular container then do the same for container as well.
精彩评论