Nodo Pai & Filho com imagens diferentes e Evento Clicável - Treeview Blackberry
Estou usando o modo de exibição de árvore no aplicativo para mostrar os dados do servidor do cliente no BlackBerry. A mesma coisa que eu consegui no aplicativo android usando itens de lista expansível. Mas aqui estou enfrentando dois problemas
Um é:Eu quero adicionar o ícone do nó pai como um ícone de pasta e nó filho deve ter ícone diferente. Por exemplo, se o item pai for imagens, os nós filhos deverão ter o ícone Imagens, se o item pai for vídeo. Então, o filho terá ícones de vídeo.
Segundo:Quando eu clico em qualquer nó filho (como o nó filho da imagem), esse nó é aberto em uma nova tela e mostra o item clicável se eu clicar na imagem ou no vídeo.
Aqui está o meu código que eu usei para obter o resultado desejado:
class CustomTreeFieldCallback implements TreeFieldCallback {
public void drawTreeItem(TreeField _tree, Graphics g, int node, int y,
int width, int indent) {
// FontFamily
FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 18);
g.setFont(font);
String text = (String) _tree.getCookie(node);
Bitmap b = Bitmap.getBitmapResource("images.png");
g.drawText(text, indent + b.getWidth(), y);
g.drawBitmap(indent, y - 15, b.getWidth(), b.getHeight(), b, 0, 0);
}
}
e
public class FilesManager extends MainScreen {
public FilesManager() {
// Set the linear background.
Bitmap background = Bitmap.getBitmapResource("background.png");
Background bg = BackgroundFactory.createBitmapBackground(background);
this.getMainManager().setBackground(bg);
String parentNode = new String("Images");
String firstChild = new String("first child");
String secondChild = new String("second child");
String thirdChild = new String("third child");
CustomTreeFieldCallback myCallback = new CustomTreeFieldCallback();
myTree = new TreeField(myCallback, Field.FOCUSABLE);
int node2 = myTree.addChildNode(0, parentNode);
myTree.addChildNode(node2, firstChild);
myTree.addChildNode(node2, secondChild);
myTree.addChildNode(node2, thirdChild);
add(myTree);
}
}
Eu também anexei o screenShot que fiz no android. Alguém me dá uma diretriz para conseguir isso em BB?