I am using a ListField
for my app to show the data in a list. Now my requirement is that i want to increase the row height of the selected item of the list.
For this, i created a GridFieldManager
a开发者_StackOverflow社区nd populated my list using this manager. I then override the onFocus()
method of this manager. But, this method is never invoked. As a result i am unable to increase the height of the selected row item.
Please help.
ListField
rows are all designed to be uniformly sized, so unfortunately you won't be able to directly change the size of one row. It's possible you can emulate it by setting it so that the row above and below draw a little bit of the focus color at the bottom and top respectively. Alternatively, you could have one field that just stays centered above whatever row is focused. Then redraw this "floating Field" with the information from the selected row.
I got it working. I faked the ListField
implementation. I removed ListField
and replaced it with VerticalFieldManager
. I adjusted its size during onfocus()
and onUnfocus()
and used sublayout()
to change the height of this manager. Its working exactly the way i want.
you can increase the row height/font text/...
as ultimately, all of the api's call canvas's paint methods
how to do:
//try playing with the font_type,font height
Font myFont = Font.getDefault().derive(Font.PLAIN, 14, Ui.UNITS_px);
private class ListCallback implements ListFieldCallback {
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
g.setFont(myFont);
String text = (String)listElements.elementAt(index);
g.drawText(text, 0, y, 0, w);
//you can increase the height of a particular row in the height parameter.
// if you want it to be specific, put an 'if conditon'
EX: if(index=1)
{
w+=10;
}
}
}
精彩评论