lwuit-List控件使用

来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 06:39 点击:
List控件的使用是很频繁的,今天就介绍一下Lwuit中List的使用方法:

    private String globalstrURL = "";

    public void initform() {
        removeAll();
        removeAllCommands();
        String[][] strAccessories = EsionData.getInstance()
                .GetSiteList("05342");
        this.addCommand(new Command("返回", 0) {
            public void actionPerformed(ActionEvent ev) {
                FormFactory.getInstance().getMainForm().show();
            }
        });
        if (strAccessories != null) {
            SiteListInfo[] accessoryinfoarray = new SiteListInfo[strAccessories.length];
            Image img = getRes().getImage("YdFj.gif");
            for (int i = 0; i < strAccessories.length; i++) {
                accessoryinfoarray[i] = new SiteListInfo(strAccessories[i][0],
                        strAccessories[i][1], img);
            }
            // 设置使得list的选中状态的层能够自适应的足够撑开
            setLayout(new BorderLayout());
            setScrollable(false);
                        //创建List并传入相应的数据
            addComponent(BorderLayout.CENTER, createList(accessoryinfoarray,
                    List.VERTICAL, new ContactsRenderer()));
            this.addCommand(new Command("确定", 1) {
                public void actionPerformed(ActionEvent ev) {
                    try {
                        EsionMIDlet.midlet.platformRequest(globalstrURL);
                    } catch (ConnectionNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            });
        } else
            addComponent(new Label("网络出现异常,没有找到任何资讯站点!"));
    }

    // List初始化
    private List createList(final SiteListInfo[] SiteLists, int orientation,
            ListCellRenderer renderer) {
        final List list = new List(SiteLists);
        list.getStyle().setBgTransparency(0);
        list.setListCellRenderer(renderer);
        list.setOrientation(orientation);
        // list列表选择焦点监听事件

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Java编程语言的八大优点
      • JVM对象生命周期详细介绍
      • Java平台上的CRM系统
      • Java 算数测试小程序
      • Command(命令模式)
      • Java 一个简单的画图程序
      • Java环境 使用Resin在NT环境下配置JSP环境
      • Java 日历的小程序
      • Java 统计代码的小工具
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1