我开发了 RSS Feed 阅读器应用程序,当我在 BB Simulator 9900 上执行应用程序时,我能够成功显示列表项,
但是当我尝试在我的真实设备 BB 曲线 9380 上执行相同的应用程序时,我无法加载我的列表项。
谁能告诉我出了什么问题?
注意:当我在我的真实设备上运行应用程序时,我会显示* Feeds Not Available *屏幕上的消息
这是我的代码:
public class RssScreen extends MainScreen implements ListFieldCallback {
public RssScreen() {
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);
}
};
_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(70);
_list.setCallback(this);
//mainManager.add(subManager);
add(subManager);
listElements.removeAllElements();
_connectionthread = new Connection();
_connectionthread.start();
}
/*RssFileReading in a Seperate Thread*/
private class Connection extends Thread {
public Connection() {
super();
}
public void run() {
Document doc;
StreamConnection conn = null;
InputStream is = null;
try {
conn = (StreamConnection) Connector .open("http://toucheradio.com/toneradio/android/toriLite/toriplaylist.xml"
+ ";deviceside=true");
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
.newInstance();
docBuilderFactory.setIgnoringElementContentWhitespace(true);
docBuilderFactory.setCoalescing(true);
DocumentBuilder docBuilder = docBuilderFactory
.newDocumentBuilder();
docBuilder.isValidating();
is = conn.openInputStream();
doc = docBuilder.parse(is);
doc.getDocumentElement().normalize();
NodeList listImg = doc.getElementsByTagName("title");
for (int i = 0; i < listImg.getLength(); i++) {
Node textNode = listImg.item(i).getFirstChild();
listElements.addElement(textNode.getNodeValue());
}
NodeList list = doc.getElementsByTagName("image");
for (int a = 0; a < list.getLength(); a++) {
Node textNode1 = list.item(a).getFirstChild();
String imageurl = textNode1.getNodeValue();
Bitmap image = GetImage.connectServerForImage(imageurl
.trim() + ";deviceside=true");
listImage.addElement(image);
}
} catch (Exception e) {
System.out.println(e.toString());
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignored) {
}
}
if (conn != null) {
try {
conn.close();
} catch (IOException ignored) {
}
}
}
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
_list.setSize(listElements.size());
subManager.add(_list);
invalidate();
}
});
} }
/*This Method is Invoked for Each title on RssFile*/
public void drawListRow(ListField list, Graphics g, int index, int y,
int width) {
String title = (String) listElements.elementAt(index);
Bitmap image = (Bitmap) listImage.elementAt(index);
try {
g.drawBitmap(xpos, ypos, w, h, image, 0, 0);
xpos = w + 20;
g.drawText(title, xpos, ypos);
} catch (Exception e) {
e.printStackTrace();
}
}
}