如何打印没有科学记数法双重价值? [英] How to print double value without scientific notation?

查看:105
本文介绍了如何打印没有科学记数法双重价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否需要关闭数的减少,类型:10000 - > 1.0E7?并开启该分区的水平。例如:1234567890 - > 1234567 890如何可以做到这一点。

Do I need to disable the reduction of numbers, type: 10000 -> 1.0E7? And turn on the partition level. For example: 1234567890 -> 1234567 890 How this can be done?

的截图显示的数字转换的结果,所以请不要再提一万! = 1.0E7 :)

The screenshot shows the results of the conversion of numbers, so please do not mention that 10,000! = 1.0E7 :)

inputType =numberSigned | numberDecimal

inputType = "numberSigned | numberDecimal"

public class CLASS extends Activity {
private EditText text1, text2, text3, text4, text5, text6,text7,text8, text9;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.LAYOUT);
     Typeface keys = Typeface.createFromAsset(getAssets(),   getString(R.string.TYPEFACE));
     TextView key = (TextView)findViewById(R.id.TEXT_VIEW);
     key.setTypeface(keys);
        text1 = (EditText) findViewById(R.id.ET1);
        text1.addTextChangedListener(watcher1);
        text2 = (EditText) findViewById(R.id.ET2);
        text2.addTextChangedListener(watcher2);
        text3 = (EditText) findViewById(R.id.ET3);
        text3.addTextChangedListener(watcher3);
        text4 = (EditText) findViewById(R.id.ET4);
        text4.addTextChangedListener(watcher4);
        text5 = (EditText) findViewById(R.id.ET5);
        text5.addTextChangedListener(watcher5);
        text6 = (EditText) findViewById(R.id.ET6);
        text6.addTextChangedListener(watcher6);
        text7 = (EditText) findViewById(R.id.ET7);
        text7.addTextChangedListener(watcher7);
        text8 = (EditText) findViewById(R.id.ET8);
        text8.addTextChangedListener(watcher8);
        text9 = (EditText) findViewById(R.id.ET9);
        text9.addTextChangedListener(watcher9);
}


TextWatcher watcher1 = new TextWatcher() {

     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());
                NumberFormat formatter = new DecimalFormat("#0.00");     
                text2.setText(String.valueOf(X(inputValue)));
                text3.setText(String.valueOf(X(inputValue)));
                text4.setText(String.valueOf(X(inputValue)));
                text5.setText(String.valueOf(X(inputValue)));
                text6.setText(String.valueOf(X(inputValue)));
                text7.setText(String.valueOf(X(inputValue)));
                text8.setText(String.valueOf(X(inputValue)));
                text9.setText(String.valueOf(X(inputValue)));


            } 
                    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) {
      }
       };

截图:

Screenshot:

推荐答案

我发现我的问题的答案: 我改变TextWatcher:

I am found the answer for my question: I am change TextWatcher:

 TextWatcher watcher8 = new TextWatcher() {
                                 public void afterTextChanged(Editable s) {
                                     if(text8.length()==0)
                                  { 
                                        return;
                                  }
                                    if (text8.hasFocus() == true && !text8.getText().equals("-")) {
                                        try{
                                        double inputValue = Float.parseFloat(text8.getText().toString());
                                            DecimalFormat df = new DecimalFormat("###,###,###,###.###");
                                            BigDecimal a = new BigDecimal(X(inputValue));
                                            BigDecimal b = new BigDecimal(X(inputValue));
                                            BigDecimal c = new BigDecimal(X(inputValue));
                                            BigDecimal d = new BigDecimal(X(inputValue));
                                            BigDecimal e = new BigDecimal(X(inputValue));
                                            BigDecimal f = new BigDecimal(X(inputValue));
                                            BigDecimal g = new BigDecimal(X(inputValue));
                                            BigDecimal h = new BigDecimal(X(inputValue));
                                            text1.setText(df.format(a));
                                            text2.setText(df.format(b));
                                            text3.setText(df.format(c));
                                            text4.setText(df.format(d));
                                            text5.setText(df.format(e));
                                            text6.setText(df.format(f));
                                            text7.setText(df.format(g));
                                            text9.setText(df.format(h));
                                        } 
                                                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) {
                            }
                        };

这篇关于如何打印没有科学记数法双重价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆