丰富列表点击事件

发布于 2025-01-02 04:34:18 字数 1311 浏览 2 评论 0原文

我使用以下代码来显示丰富列表。

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.table.*;

public class RichListDemo extends UiApplication
{
public static void main(String[] args)
{
    RichListDemo theApp = new RichListDemo();       
    theApp.enterEventDispatcher();
}

public RichListDemo()
{        
    pushScreen(new RichListScreen());
}


private static class RichListScreen extends MainScreen
{
    public RichListScreen()
    {
        super(Manager.NO_VERTICAL_SCROLL);

        setTitle("Rich List Demo");

        add(new LabelField("BlackBerry Devices", LabelField.FIELD_HCENTER));
        add(new SeparatorField());

        Manager mainManager = getMainManager();

        RichList list = new RichList(mainManager, true, 2, 1);

        Bitmap bitmap1 = Bitmap.getBitmapResource("9500.png");
        Bitmap bitmap2 = Bitmap.getBitmapResource("9000.png");

        list.add(new Object[] {bitmap1, "Device 1", "BlackBerry Smartphone 9500", "Description of Device 1."});
        list.add(new Object[] {bitmap2, "Device 2", "BlackBerry Smartphome 9000", "Description of Device 2."});
    }
}
}

如何实现富豪榜的点击事件?当我单击列表时,我想显示一个对话框。是否可以 ?。

I used the following code to display a rich list.

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.table.*;

public class RichListDemo extends UiApplication
{
public static void main(String[] args)
{
    RichListDemo theApp = new RichListDemo();       
    theApp.enterEventDispatcher();
}

public RichListDemo()
{        
    pushScreen(new RichListScreen());
}


private static class RichListScreen extends MainScreen
{
    public RichListScreen()
    {
        super(Manager.NO_VERTICAL_SCROLL);

        setTitle("Rich List Demo");

        add(new LabelField("BlackBerry Devices", LabelField.FIELD_HCENTER));
        add(new SeparatorField());

        Manager mainManager = getMainManager();

        RichList list = new RichList(mainManager, true, 2, 1);

        Bitmap bitmap1 = Bitmap.getBitmapResource("9500.png");
        Bitmap bitmap2 = Bitmap.getBitmapResource("9000.png");

        list.add(new Object[] {bitmap1, "Device 1", "BlackBerry Smartphone 9500", "Description of Device 1."});
        list.add(new Object[] {bitmap2, "Device 2", "BlackBerry Smartphome 9000", "Description of Device 2."});
    }
}
}

How to implement click event in the Rich List ?. When i click the List, i want to show a dilog box. Is it possible ?.

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

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

发布评论

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

评论(2

ま柒月 2025-01-09 04:34:18

您无法确定 RichList 中选定的行。如果您想具有点击功能,可以使用 TableView 而不是 RichListRichList 应用于您想要显示的只读项目。如果您想捕获输入和/或允许用户进行选择,则应使用 TableView

您可以使用 链接用于创建表格视图并在行中添加可点击字段

You cannot determine the selected row in a RichList. You can use a TableView instead of RichList if you want to have click functionality . RichList should be used for read only items you want to display. If you want to capture input and/or allow a user to make a selection then a TableView should be used.

You can use this link to create a table view and add clickable fields in the row

黎夕旧梦 2025-01-09 04:34:18

是的,这是可能的。请看下面的代码:

        final RichList list = new RichList(vfm, false,3, 1);

        list.add(new Object[] {"jak się masz", "كيف حالك؟", "Description of Device 1." ,new SeparatorField()});
        list.add(new Object[] { "Device 2", "BlackBerry Smartphome 9000", "Description of Device 2.",new SeparatorField()});
        list.add(new Object[] { "Device 3", "BlackBerry Smartphome 9000", "Description of Device 3.",new SeparatorField()});
        list.add(new Object[] { "Device 4", "BlackBerry Smartphome 9000", "Description of Device 4.",new SeparatorField()});
        list.add(new Object[] { "Device 5", "BlackBerry Smartphome 9000", "Description of Device 5.",new SeparatorField()});
        list.add(new Object[] { "Device 6", "BlackBerry Smartphome 9000", "Description of Device 6.",new SeparatorField()});

        list.setFocusPolicy(TableController.ROW_FOCUS);

     list.setCommand(new Command(new CommandHandler() 
     {
        /**
         * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata, Object)
         */
         public void execute(ReadOnlyCommandMetadata metadata, Object context) 
         {
        Dialog.alert("executed!");  
        TableModel tableModel = list.getModel();
               Object[] objArray = (Object[])tableModel.getRow(list.getFocusRow());                                
               int DISPLAY_NAME = 0;
            Dialog dialog = new Dialog(Dialog.D_OK, (String)objArray[DISPLAY_NAME], 0, null, 0 );          

              dialog.doModal();                                

         }
     }));

Yes it is possible. See the following code:

        final RichList list = new RichList(vfm, false,3, 1);

        list.add(new Object[] {"jak się masz", "كيف حالك؟", "Description of Device 1." ,new SeparatorField()});
        list.add(new Object[] { "Device 2", "BlackBerry Smartphome 9000", "Description of Device 2.",new SeparatorField()});
        list.add(new Object[] { "Device 3", "BlackBerry Smartphome 9000", "Description of Device 3.",new SeparatorField()});
        list.add(new Object[] { "Device 4", "BlackBerry Smartphome 9000", "Description of Device 4.",new SeparatorField()});
        list.add(new Object[] { "Device 5", "BlackBerry Smartphome 9000", "Description of Device 5.",new SeparatorField()});
        list.add(new Object[] { "Device 6", "BlackBerry Smartphome 9000", "Description of Device 6.",new SeparatorField()});

        list.setFocusPolicy(TableController.ROW_FOCUS);

     list.setCommand(new Command(new CommandHandler() 
     {
        /**
         * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata, Object)
         */
         public void execute(ReadOnlyCommandMetadata metadata, Object context) 
         {
        Dialog.alert("executed!");  
        TableModel tableModel = list.getModel();
               Object[] objArray = (Object[])tableModel.getRow(list.getFocusRow());                                
               int DISPLAY_NAME = 0;
            Dialog dialog = new Dialog(Dialog.D_OK, (String)objArray[DISPLAY_NAME], 0, null, 0 );          

              dialog.doModal();                                

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