A
A
Artix2014-08-25 08:53:03
Android
Artix, 2014-08-25 08:53:03

edittext. How to turn off abbreviation and turn on digit splitting?

I am programming for Android OS. I can't find an answer to this question: Is it necessary to turn off number reduction, like: 10000 -> 1.0E7? And enable splitting into bits. For example: 1234567890 -> 1 234 567 890. How can this be done? Thanks in advance for your replies. 66681d8c58394a3483fa3e6e8a06f908.png
PS The screenshot shows the results of converting numbers, so please don't mention that 10000 != 1.0E7 :)
PPS inputType="numberSigned|numberDecimal"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artix, 2014-09-04
@nikkorejz

I'll just leave it here:

TextWatcher watcher1 = new TextWatcher() {

        @SuppressWarnings("static-access")
        public void afterTextChanged(Editable s) {
            if(text1.length()==0)
            {
                return;
            }

            if (text1.hasFocus() == true && !text1.getText().equals("-")) {

                try{
                    double inputValue = Float.parseFloat(text1.getText().toString());
                    DecimalFormat df = new DecimalFormat("###,###,###,###.####################");
                    BigDecimal a = new BigDecimal(Value1(inputValue));
                    BigDecimal b = new BigDecimal(Value2(inputValue));                    
                    text2.setText(df.format(a));
                    text3.setText(df.format(b));
                }
                catch (NumberFormatException e){

                    return;
                }
            }
        }
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
        }
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {


        }
    };

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question