黑莓中的列表字段索引

发布于 2024-12-14 05:18:10 字数 1779 浏览 1 评论 0原文

我正在浏览 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);

I m going through ListField,..I m getting problem when i click on the selected index....

I want the code,when i click on the selected index,it is showing all the profiles for the particular index

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

using switch case

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羅雙樹 2024-12-21 05:18:10

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

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

ListFieldCallback.drawListRow() is just for drawing a list item representation on UI.

Looks like you are looking for how to catch on-list click event. If yes, then override ListField.navigationClick().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文