小编tw-*_*w-S的帖子

带有货币格式的EditText

我有一个EditText,我想在其中显示货币:

    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    input.addTextChangedListener(new CurrencyTextWatcher());
Run Code Online (Sandbox Code Playgroud)

有:

public class CurrencyTextWatcher implements TextWatcher {

boolean mEditing;

public CurrencyTextWatcher() {
    mEditing = false;
}

public synchronized void afterTextChanged(Editable s) {
    if(!mEditing) {
        mEditing = true;

        String digits = s.toString().replaceAll("\\D", "");
        NumberFormat nf = NumberFormat.getCurrencyInstance();

        try{
            String formatted = nf.format(Double.parseDouble(digits)/100);
            s.replace(0, s.length(), formatted);
        } catch (NumberFormatException nfe) {
            s.clear();
        }

        mEditing = false;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想用户看一个只有数字的键盘,这就是我打电话的原因

input.setInputType(InputType.TYPE_CLASS_NUMBER);
Run Code Online (Sandbox Code Playgroud)

在我的EditText上.但是,它不起作用.我看到输入的数字没有任何格式.但是:如果我不通过input.setInputType(InputType.TYPE_CLASS_NUMBER)设置inputType,则格式化工作完美.但是用户必须使用常规键盘,这不是很好.如何使用数字键盘并在EditText中查看正确的货币格式?谢谢.

android

13
推荐指数
2
解决办法
2万
查看次数

matlab中的严重错误解决 - 我该怎么办?

这篇文章在Solve中更新我的问题找到错误的解决方案?

鉴于x中的"简单"功能:

f = (x + 3/10)^(1/2) - (9*(x + 3/10)^5)/5 - (x + 3/10)^6 + (x - 1)/(2*(x + 3/10)^(1/2));
Run Code Online (Sandbox Code Playgroud)

通过电话找到零

solve(f,x)
Run Code Online (Sandbox Code Playgroud)

这产生3个零:

 ans =

 0.42846617518653978966562924618638
 0.15249587894102346284238111155954
 0.12068186494007759990714181154349
Run Code Online (Sandbox Code Playgroud)

简单地看一下图表显示第三个根是无意义的:

功能有2个零

我有一个严重的问题,因为我需要从上面的向量中检索最小的零.调用min(ans)返回错误的零.我该怎么做才能解决?

matlab symbolic-math solver

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

在ScrollView中拉伸TableLayout

我有这个TableLayout:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout" android:layout_height="fill_parent"
android:layout_alignParentBottom="true" android:scrollbars="horizontal|vertical"
android:layout_width="fill_parent" android:scrollbarStyle="outsideInset">
<HorizontalScrollView android:id="@+id/horizontalView" android:layout_height="fill_parent"
            android:layout_width="fill_parent">
    <TableLayout android:id="@+id/reportTableLayout"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:stretchColumns="1">
    </TableLayout>
</HorizontalScrollView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我已将所有layout_width设置为fill_parent,但我的Table列似乎没有拉伸并填充宽度空间的其余部分.左边还有一个边距,但我希望我的桌子可以伸展整个屏幕宽度.有任何想法吗?谢谢.

user-interface android scrollview tablelayout

0
推荐指数
1
解决办法
3020
查看次数