gpt4 book ai didi

java - 黑莓 java ListField

转载 作者:行者123 更新时间:2023-12-02 07:34:59 26 4
gpt4 key购买 nike

我为Blackberry(java)开发了一个Rss应用程序,并且成功地从Rss文件中显示了标题(需要在线播放的广播 channel 列表)。我已经开发了用于播放这些广播 channel 列表的代码,但我的要求是播放第一个 channel (第一个列表)当我的列表最初显示( channel 列表)时,任何人都可以帮助我在哪里可以编写我的逻辑(默认情况下播放第一个 channel )以便在我的 channel 立即显示后执行?

这是我的 Rss 代码:

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();
}

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());
image=textNode.getNodeValue();
}
NodeList list = doc.getElementsByTagName("image");
for (int a = 0; a < list.getLength(); a++) {
Node textNode1 = list.item(a).getFirstChild();
listImage.addElement(textNode1.getNodeValue());
}





}
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();
}
});
}

}


public void drawListRow(ListField list, Graphics g, int index, int y, int w)
{
String title=(String)listElements.elementAt(index);
String image=(String)listImage.elementAt(index);
// Bitmap image1= getBitmapFromUrl(image);


System.out.println("Title"+title);
System.out.println("Image"+image);
int yPos = 0+y;
g.drawLine(0, yPos, w, yPos);

g.drawText(title, 0, y, 0, w);
// g.drawBitmap(0,y,image1.getWidth(),image1.getHeight(),image1,0,0);

}


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) {




}

}

最佳答案

关于java - 黑莓 java ListField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12386561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com