小编Ric*_*elo的帖子

Android数据绑定上的字符串比较

我正在尝试与android XML数据绑定进行字符串比较,但我没有得到正确的结果.

在代码中评估我的表达式,我尝试notice.action == "continue"这是错误的.当然,在数据绑定中,这也是错误的.

android:textColor='@{ notice.action == "continue" ? @color/enabledPurple : @color/disabledGray}'
Run Code Online (Sandbox Code Playgroud)

只有notice.action.equals("continue")通过代码才能实现.这是预期的行为.我的问题是我无法通过数据绑定表达式完成此操作,因为它不会运行类似的方法equals.我该怎么做才能将比较表达式替换为另一个有效的比较表达式?

我正在使用本指南.

编辑:我错了,XML中允许使用方法.这样做了:

android:textColor='@{ notice.action.equals("continue") ? @color/enabledPurple : @color/disabledGray}'
Run Code Online (Sandbox Code Playgroud)

data-binding comparison android string-comparison

17
推荐指数
3
解决办法
6692
查看次数

MySQL Java更新语法

我只是想在我的应用程序中使用更新,但我不能.一个控制台,这个mysql命令工作,但在这里,没有.

好吧,我在我的程序中使用它:

    conexao = poolMySQL.connect();
    final String sql = "UPDATE professor  SET codlocal = ?  WHERE codprof = ?";

    pstmt = conexao.prepareStatement(sql);


    pstmt.setInt(1, local);
    pstmt.setInt(2, id);
    try {
        pstmt.executeUpdate(sql);
    } catch (SQLException ex) {
        Logger.getLogger(ProfessorDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
Run Code Online (Sandbox Code Playgroud)

提醒一下,codlocal是另一个表中的外键,名为Localidade.我看到了一些关于加入的例子,但我无法想象这对我有什么影响.

我得到了这个:

    Grave: null
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?  WHERE codprof = ?' at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at …
Run Code Online (Sandbox Code Playgroud)

java mysql syntax syntax-error

2
推荐指数
1
解决办法
1098
查看次数