How to horizontally and vertically expand CustomItem?
Posted on 2007-08-12
Dear J2ME Experts,
I have written a subclass of CustomItem named MyCustomItem.
I want to add the object of this class to myForm (Form object) so that added MyCustomItem object is maximally horizontally and vertically expanded.
Of course, this MyCustomItem object would be the only item on this form.
This is the code sample that I used:
MyCustomItem myitem = new MyCustomItem();
myItem.setLayout(Item.LAYOUT_EXPAND | Item.LAYOUT_VEXPAND);
MyForm myform = new MyForm();
The problem is that getPrefContentWidth() and getPrefContentHeight() methods of MyCustomItem must be overrided, and it is obvious that J2ME LayoutManager uses this values to calculate dimensions of myitem, and ignores my requests for expanding.
Of course, now, in the code-writting time I don't know user-screen dimensions so I can't return valid values from this methods.
I would really appreciate any help on this subject,
Thank you in advance,