11-28-2011 05:32 AM
I am using a Customized Listfield where i am fetching content from the server and putting.I am displaying an image and a text in each row.The problem i am facing is that,after the images has been loaded,it doesnt get reflected.I have to scroll to see the effect.I have used listnew.getManager().invalidate() laso,but no use.Please help
Solved! Go to Solution.
11-28-2011 05:38 AM
11-28-2011 05:40 AM
I am populating the listfield,and in the vector i can see the datas,its get loaded also,but the problem is that it doesnt get reflected automatically,wen i scrool down one row by another,i mages start to show up.So the problem is not with populating the listfield but with repainting of the listfield and d manager automatically
11-28-2011 05:47 AM
Hi,
Try like this,
UiApplication.getUiApplication.getActiveScreen().i
Thanks.
11-28-2011 06:08 AM
The problem still persists
11-28-2011 06:39 AM
Then may be the problem not with the repaint. can you post small snippet, then i can help you
11-28-2011 06:54 AM
listnew.setCallback(this);
rows = new Vector();
for (int x = 0; x < mSCtaegory.size(); x++) {
Hashtable hs = (Hashtable) mSCtaegory.elementAt(x);
row = new TableRowManager();
FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.UNKNOWN_FONT, 13);
HTTPManager engine = new HTTPManager();
BitmapField bitmap = new BitmapField(Bitmap.getBitmapResource("30x30.png"))
HTTPGetTask img = new HTTPGetTask(this, (String) hs.get("img"), bitmap, 30, 30);
img.go();
row.add(bitmap);
LabelField task = new LabelField(hs.get("title"), LabelField.USE_ALL_WIDTH) {
public void paint(Graphics g) {
g.setColor(0x9e0a62);
super.paint(g);
}
protected void layout(int width, int height) {
super.layout(width, height);
setExtent(Display.getWidth(), Display.getHeight());
}
};
task.setFont(font);
row.add(task);
rows.addElement(row);
}
listnew.setSize(rows.size());
FontFamily fontFamilynew[] = FontFamily.getFontFamilies();
Font fontnew = fontFamilynew[1].getFont(FontFamily.SFF4_FONT, 16);
headertitle = new LabelField(title, DrawStyle.ELLIPSIS) {
public void paint(Graphics g) {
g.setColor(0x802d6e);
super.paint(g);
}
protected void layout(int width, int height) {
super.layout(width, height);
}
};
headertitle.setFont(fontnew);
gridbackManager = new VerticalFieldManager(VerticalFieldManager.NO_HORIZ
protected void paintBackground(Graphics graphics) {
graphics.drawBitmap(0, 0, backbitmap.getWidth(), backbitmap.getHeight(), backbitmap, 0, 0);
super.paintBackground(graphics);
}
protected void sublayout(int maxWidth, int maxHeight) {
int width = backbitmap.getWidth();
int height = backbitmap.getHeight();
super.sublayout(width, height);
layoutChild(_vfm, width, height);
setPositionChild(_vfm, 0, 0);
setExtent(width, height);
}
};
mainlayout = new VerticalFieldManager(VerticalFieldManager.NO_HORIZ
protected void paintBackground(Graphics graphics) {
graphics.drawBitmap(0, 0, backbitmap.getWidth(), backbitmap.getHeight(), backbitmap, 0, 0);
super.paintBackground(graphics);
}
protected void sublayout(int maxWidth, int maxHeight) {
int width = backbitmap.getWidth();
int height = backbitmap.getHeight();
super.sublayout(width, height);
layoutChild(backbittopfield, maxWidth, maxHeight);
setPositionChild(backbittopfield, 15, 10);
layoutChild(headertitle, maxWidth, maxHeight);
setPositionChild(headertitle, 25, 13);
layoutChild(gridbackManager, maxWidth, maxHeight);
setPositionChild(gridbackManager, 15, 33);
layoutChild(backbitbottomfield, maxWidth, maxHeight);
setPositionChild(backbitbottomfield, 15, 184);
setExtent(Display.getWidth(), Display.getHeight());
}
};
_vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH) {
public void paint(Graphics g) {
super.paint(g);
}
protected boolean navigationMovement(int dx, int dy, int status, int time) {
this.invalidate();
return super.navigationMovement(dx, dy, status, time);
}
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(292, 150);
layoutChild(listnew, maxWidth, maxHeight);
setPositionChild(listnew, 0, 0);
setExtent(292, 150);
}
};
listnew.setEmptyString(empty, 0);
_vfm.add(listnew);
mainlayout.setBackground(bg);
mainlayout.add(backbittopfield);
mainlayout.add(headertitle);
gridbackManager.add(_vfm);
mainlayout.add(gridbackManager);
mainlayout.add(backbitbottomfield);
add(headerbitmapfield);
add(mainlayout);
UiApplication.getUiApplication().getActiveScreen()
11-28-2011 07:15 AM
I think you are using the following two lines to download images , right?
HTTPGetTask img = new HTTPGetTask(this, (String) hs.get("img"), bitmap, 30, 30);
img.go();
If so, dont write invalidate methods in the class which you sent.
in HTTPGetTaskImg.go() method after download the image write like this
UiApplication.getUiApplication().getActiveScreen()
If above two lines are not to download image, you may wrote code for download image, use the above same line after downloading the image in image downloader function.
Thanks.
11-28-2011 09:29 AM
You have a lot of elements which are irrelevant to your current problem, some of them with a very wrong code.
For example:
- painting something in paintBackground then calling super.paintBackground is pointless - it will just paint over your bitmap unless super.paintBackground doesn't do anything (which I doubt)
- your sublayout() code, on the other hand, calls super.sublayout then starts tinkering with fields layouts and positions. In this case it is much safer to use Manager instead of VerticalFieldManager and drop the call to super.sublayot altogether.
The only code that is totally missing from what you've shown so far is the code dealing with ListField - drawListRow in particular. If you can show that and at least describe what HTTPGetTask does upon downloading the image, we will be able to help you better.
11-29-2011 04:09 AM
Thank you so much.It got fixed ![]()