在黑莓中列出字段索引

时间:2011-11-09 07:40:14

标签: blackberry listfield

我正在浏览ListField,...当我点击所选索引时遇到问题....

我想要代码,当我点击所选索引时,它会显示特定索引的所有配置文件

  public class ListEmployees extends MainScreen implements ListFieldCallback
    {
             ListField list;
        String[]  items= {"Srikanth","Pradeep","Ranjith"}; 
        public ListEmployees()
        {
            setTitle("List Screen");
            list = new ListField();
            list.setSize(3);
            list.setCallback(this);

            add(list);
        }
  

使用开关案例

public void drawListRow(ListField listField, Graphics g, int index,int y, int width) 
{
    int a= listField.getSelectedIndex();
    g.drawText(items[a], 0, y,0,50);

    switch(a)
    {
    case 0 :
        g.setColor(Color.GREEN);
        Bitmap srikanthImg = Bitmap.getBitmapResource("srikanth.jpg");
        if(list.getSelectedIndex()==0)
            showMessage(srikanthImg,"Srikanth","1363");
        else 
            break;
        //Dialog.alert("The selected element is: " + Integer .toString ());
        break;
    case 1 :
    g.setColor(Color.GREEN);
    Bitmap PradeepImg = Bitmap.getBitmapResource("pradeep.jpg");
    showMessage(PradeepImg,"Pradeep","1303");
    break;
case 2 :
    g.setColor(Color.GREEN);
    Bitmap ranjithImg = Bitmap.getBitmapResource("ranjith.jpg");
    showMessage(ranjithImg,"ranjith","1333");
    break;

default :
        Dialog.alert("No Information Found !!!");
    }
}
private void showMessage(Bitmap map, String name1, String empId1) {
    // TODO Auto-generated method stub

    String data = name1 + "\n"+empId1;
    UiEngine ui = Ui.getUiEngine();
    Screen screen = new Dialog(Dialog.D_OK, data, Dialog.OK, map, FIELD_HCENTER);
    ui.queueStatus(screen, 1, true);

1 个答案:

答案 0 :(得分:0)

ListFieldCallback.drawListRow()仅用于在UI上绘制列表项表示。

看起来您正在寻找如何捕获列表上的点击事件。如果是,则覆盖ListField.navigationClick()