简体   繁体   English

“话语提示”小数公告

[英]TalkBack decimal announcements

I'm having a problem with Talkback. 我在对讲中遇到问题。 In my string I have the following number. 在我的字符串中,我有以下数字。

1,827 1827

it's a Dutch number so the number means: 1 euro and 82,7 cents. 这是一个荷兰数字,所以数字表示: 1欧元和82.7美分。

But Talkback is saying: 18 hundred and 27 euro. 但是Talkback却说:18,27 欧元。

So this problem only occurs when I have a number with more than 2 decimals. 因此,只有当我的数字超过2个小数时,才会出现此问题。 How to fix this issue? 如何解决这个问题?

---EDIT--- - -编辑 - -

When I'm reading this page: https://english.stackexchange.com/questions/62397/reading-out-decimal-numbers-in-english 当我阅读此页面时: https : //english.stackexchange.com/questions/62397/reading-out-decimal-numbers-in-english

it seems I must pronounce the number 1,827 as the following: 看来我必须将数字1,827发音如下:

one point eight two seven instead to act if it is a number. 如果是数字,则一分八二七取而代之。 How to do this? 这个怎么做?

---EDIT--- - -编辑 - -

I included the following: 我包括以下内容:

 StringTokenizer stringTokenizer = new StringTokenizer(value, ".");
    String currencyBeforeComma = null;
    String currencyAfterComma = null;

    while (stringTokenizer.hasMoreTokens()) {
        currencyBeforeComma = stringTokenizer.nextToken();
        currencyAfterComma = stringTokenizer.nextToken();
    }

    result = currencyBeforeComma + " point " + currencyAfterComma;

So now its pronouncing: one point eighthunderd twentyseven . 所以现在它的发音是: 一点八十七分,第二十七分 So this is still now what i want. 所以这仍然是我现在想要的。

---EDIT--- - -编辑 - -

String value = 1,827;        
String result = "";
        for (Character chars : value.toCharArray()) {
            result = result + chars + " ";
        }
        String replace = result.replace(getResources().getString(R.string.accessibility_decimal_separator), getResources().getString(R.string.accessibility_decimal_separator_text));
        return replace;

This is what i did. 这就是我所做的。 I created a whitespace for every char in the value string and for the , or . 我为值字符串中的每个字符以及或创建了一个空格。 I replaced it with a comma or point text. 我用逗号或点文本替换了它。

This works for now but it isn't a clean solution. 目前可以使用,但这不是一个干净的解决方案。 If anybody else has a better solution, please share 如果其他人有更好的解决方案,请分享

Try this and modify your as per your requirement 尝试此操作并根据需要修改您的

TextView currencylbl = (TextView) findViewById(R.id.currencylbl);
        boolean countryCurrency = true;
        String currency = "1,827";
    if(countryCurrency==true && currency.contains(",")){

            StringTokenizer stringTokenizer = new StringTokenizer(currency, ",");
            String currencyBeforeComma = null;
            String currencyAfterComma = null;

            while (stringTokenizer.hasMoreTokens()) {
                currencyBeforeComma = stringTokenizer.nextToken();
                currencyAfterComma = stringTokenizer.nextToken();
                currencylbl.setText(currency);
            } 

            Double double1 = Double.parseDouble(currencyAfterComma);
            double1 = Double.parseDouble(currencyBeforeComma)+double1/1000;
            currencylbl.setContentDescription(double1+"");
        }

countryCurrency refers to particular Country currency boolean. countryCurrency指特定的国家/地区货币布尔值。 Also modify as per your requirement. 还可以根据您的要求进行修改。

            Double double1 = Double.parseDouble(currencyAfterComma);
            double1 = Double.parseDouble(currencyBeforeComma)+double1/1000;
            currencylbl.setContentDescription(double1+"");

xml is XML是

<TextView 
    android:id="@+id/currencylbl"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="24sp"
    />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM