Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Blackberry List with Image from Rss Feed

I developed an Rss Feed reader for Blackberry java,and i successfully displayed titles from Rss URL.but my requirement is displaying images and titles from Rss URL.In my drawListRow method i am able to retrieve the titles and image URL's from Rss,but i am not getting what is the code i need to write in the method to display image and title on screen?

 

Here my code:

public class RssScreen extends MainScreen implements ListFieldCallback,FieldChangeListener {
Connection _connectionthread;
private static ListField _list;
String image;
String title;
private static Vector listElements = new Vector();
private static Vector listImage = new Vector();

public long mycolor ;
VerticalFieldManager mainManager;
VerticalFieldManager subManager;
int selectedList;
Radio radio;

public RssScreen(){
final Bitmap backgroundBitmap = Bitmap.getBitmapResource("blackbackground.png");

mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )
{

public void paint(Graphics graphics)
{
graphics.drawBitmap(0, 0, Display.getWidth(),Display.getHeight(),backgroundBitmap, 0, 0);

super.paint(graphics);
}

};

subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR )
{
protected void sublayout( int maxWidth, int maxHeight )
{
int displayWidth = Display.getWidth();
int displayHeight = Display.getHeight();

super.sublayout( displayWidth, displayHeight);
setExtent( displayWidth, displayHeight);
}
};


add(mainManager);


_list = new ListField()

{
protected boolean navigationClick(int status, int time)
{
return true;
}
public void paint(Graphics graphics)

{
graphics.setColor((int) mycolor);
super.paint(graphics);

}

};
mycolor = 0x00FFFFFF;
_list.invalidate();
_list.setEmptyString("* Feeds Not Available *", DrawStyle.HCENTER);
_list.setRowHeight(50);
_list.setCallback(this);
mainManager.add(subManager);
listElements.removeAllElements();
_connectionthread = new Connection();
_connectionthread.start();
}


}


public void drawListRow(ListField list, Graphics g, int index, int y, int w)
{

radio=(Radio)listElements.elementAt(index);
System.out.println("Title"+radio.getTitle());
System.out.println("ImageURL"+radio.getImage());
int yPos = 0+y;
g.drawLine(0, yPos, w, yPos);
g.drawText(radio.getTitle(), 5, 15+y, 0, w);
}


public Object get(ListField list, int index)
{
return listElements.elementAt(index);
}
public int indexOfList(ListField list, String prefix, int string)
{
return listElements.indexOf(prefix, string);
}
public int getPreferredWidth(ListField list)
{
return Display.getWidth();
}
public void insert(String toInsert, int index) {
listElements.addElement(toInsert);
}

public void fieldChanged(Field field, int context) {

 


}

}

 

 

Highlighted
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Blackberry List with Image from Rss Feed

everything your listfield should display is done in drawListRow.
currently you draw a line and a text, you can also draw a bitmap there.
i would suggest to set the rowheight to a value your images fit (outside of drawlistrow!) and use g.drawBitmap to paint the list row.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter