[英]TalkBack decimal announcements
我在對講中遇到問題。 在我的字符串中,我有以下數字。
1827
這是一個荷蘭數字,所以數字表示: 1歐元和82.7美分。
但是Talkback卻說:18,27 歐元。
因此,只有當我的數字超過2個小數時,才會出現此問題。 如何解決這個問題?
- -編輯 - -
當我閱讀此頁面時: https : //english.stackexchange.com/questions/62397/reading-out-decimal-numbers-in-english
看來我必須將數字1,827發音如下:
如果是數字,則一分八二七取而代之。 這個怎么做?
- -編輯 - -
我包括以下內容:
StringTokenizer stringTokenizer = new StringTokenizer(value, ".");
String currencyBeforeComma = null;
String currencyAfterComma = null;
while (stringTokenizer.hasMoreTokens()) {
currencyBeforeComma = stringTokenizer.nextToken();
currencyAfterComma = stringTokenizer.nextToken();
}
result = currencyBeforeComma + " point " + currencyAfterComma;
所以現在它的發音是: 一點八十七分,第二十七分 。 所以這仍然是我現在想要的。
- -編輯 - -
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;
這就是我所做的。 我為值字符串中的每個字符以及或創建了一個空格。 我用逗號或點文本替換了它。
目前可以使用,但這不是一個干凈的解決方案。 如果其他人有更好的解決方案,請分享
嘗試此操作並根據需要修改您的
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指特定的國家/地區貨幣布爾值。 還可以根據您的要求進行修改。
Double double1 = Double.parseDouble(currencyAfterComma);
double1 = Double.parseDouble(currencyBeforeComma)+double1/1000;
currencylbl.setContentDescription(double1+"");
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.