如何更改EditText的行为以输入货币?

时间:2018-05-04 07:18:21

标签: java android

我需要一种货币类型EditText并且当前使用它: https://github.com/faranjit/currency_edittext

问题是,你必须输入十进制字段。

错误:

如果您想输入 $ 1 ,则需要按1-0-0

如果您想输入 $ 1.5 ,则需要按1-5-0

但我想要达到的目的是:

如果您想输入 $ 1 ,只需按1

如果您想输入 $ 1.5 ,请按1-DOT-5

我应该如何修改此代码才能像这样工作?

2 个答案:

答案 0 :(得分:0)

这适用于我尝试做到这一点

/*
 * Returns true if given expr is safe to evaluate on the foreign server.
 */
bool
is_foreign_expr(PlannerInfo *root,
                RelOptInfo *baserel,
                Expr *expr)
{
...
    /*   
     * An expression which includes any mutable functions can't be sent over
     * because its result is not stable.  For example, sending now() remote
     * side could cause confusion from clock offsets.  Future versions might
     * be able to make this choice with more granularity.  (We check this last
     * because it requires a lot of expensive catalog lookups.)
     */
    if (contain_mutable_functions((Node *) expr))
        return false;

    /* OK to evaluate on the remote server */
    return true;
}

答案 1 :(得分:0)

设置输入类型编号。

为此,请将android:inputType="numberDecimal"替换为android:inputType="number"