Dialog和add(Field)

来源:互联网 发布:网络教师兼职平台 编辑:程序博客网 时间:2024/05/01 18:54

正确写法:

------------

   private void showUserInfo(){
        final Hashtable userInfo = this.reader.getUserInfo();

        UiApplication.getUiApplication().invokeLater(
                new Runnable(){
                        public void run(){                            
                            if (null == userInfo){
                                Dialog.inform("请先登录读取个人资料");
                                return;
                            }
                            _this.add(new LabelField("头像:" + userInfo.get("img")));
                            _this.add(new LabelField("用户ID:" + userInfo.get("id")));
                            _this.add(new LabelField("用户名:" + userInfo.get("name")));
                            _this.add(new LabelField("姓名:" + userInfo.get("real")));
                            _this.add(new LabelField("吸墨币:" + userInfo.get("money")));
                            _this.add(new LabelField("登录状态:" + (userInfo.get("isAuth").equals(Boolean.TRUE)?"是":"否")));
                            _this.add(new LabelField("用户编号:" + userInfo.get("no.")));
                            _this.add(new LabelField("QQ:" + userInfo.get("qq")));
                            _this.add(new LabelField("MSN:" + userInfo.get("msn")));
                            _this.add(new LabelField("手机号:" + userInfo.get("phone")));
                            _this.add(new LabelField("信用:" + userInfo.get("credit")));
                            _this.add(new LabelField("会员称号:" + userInfo.get("title")));
                            _this.add(new LabelField("级别:" + userInfo.get("level")));
                            _this.add(new LabelField("地址:" + userInfo.get("addr")));
                        }
                }
        );        
        
    }

------------

如果把dialog放到外面(去掉UiApplication.getUiApplication().invokeLater),就会提示,非事件线程不允许使用的异常;

add会提示event no lock,也就是它直接放到Screen构造中才能直接这样用.否则得放到事件或是队列中.

原创粉丝点击