blackberry - it displays only text,but not the image -
i developed code below.in used listfield ,one bitmapfield , 1 label field,when run ,it displays text on list field row,but not image don't know did mistake,so,plz,any 1 me know did mistake help
class tasklistfield extends mainscreen implements listfieldcallback { private vector rows; private bitmap p1; listfield list; tablerowmanager row; public tasklistfield() { super(); list=new listfield() { protected void drawfocus(graphics graphics, boolean on) { } }; list.setrowheight(40); list.setemptystring("hooray, no tasks here!", drawstyle.hcenter); list.setcallback(this); p1 = bitmap.getbitmapresource("res/images/10.png"); rows = new vector(); (int x = 1; x < 13; x++) { row = new tablerowmanager(); labelfield task = new labelfield("" + string.valueof(x), drawstyle.ellipsis); row.add(task); row.add(new bitmapfield(p1)); rows.addelement(row); } list.setsize(rows.size()); add(list); } // listfieldcallback implementation public void drawlistrow(listfield listfield, graphics g, int index, int y, int width) { tablerowmanager rowmanager = (tablerowmanager) rows .elementat(index); rowmanager.drawrow(g, 0, y, width, list.getrowheight()); } private class tablerowmanager extends manager { public tablerowmanager() { super(0); } public void drawrow(graphics g, int x, int y, int width, int height) { layout(width, height); setposition(x, y); g.pushregion(getextent()); // paint manager's controlled fields. subpaint(g); g.setcolor(0x00cacaca); g.drawline(0, 0, getpreferredwidth(), 0); // restore graphics context. g.popcontext(); } protected void sublayout(int width, int height) { int preferredwidth = getpreferredwidth(); field field = getfield(0); layoutchild(field, 30, 30); setpositionchild(field, 0, 0); field = getfield(1); layoutchild(field, 40, 25); setpositionchild(field, 120, 10); setextent(preferredwidth, getpreferredheight()); } // preferred width of row defined list renderer. public int getpreferredwidth() { return graphics.getscreenwidth(); } // preferred height of row "row height" defined in // enclosing list. public int getpreferredheight() { return list.getrowheight(); } } public object get(listfield listfield, int index) { // todo auto-generated method stub return null; } public int getpreferredwidth(listfield listfield) { // todo auto-generated method stub return 0; } public int indexoflist(listfield listfield, string prefix, int start) { // todo auto-generated method stub return 0; }
the image path not necessary put
p1 = bitmap.getbitmapresource (" res/images/10.png ");
only needs
p1 = bitmap.getbitmapresource (" 10.png ");
Comments
Post a Comment