lang.NumberFormatException在android系统 [英] lang.NumberFormatException in android

查看:113
本文介绍了lang.NumberFormatException在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code这不只是在后台线程读取从DB一些值,并使用这些值我使用的是jar.For我使用的价值为每个阵列线图绘制折线图和问题是,第三个,我传递给绘制线型图的构造是浮动....

I have the following code which does nothing but reading some values from a DB in a background thread and using the values I draw a Line chart using a jar.For the line chart I use for value for each array and the problem is that the third that I pass to the constructor that draws the LineChart is float....

float[] viteza;

String[] time;

int contor=0;


public void onResume() {

    super.onResume();

    init_task = new InitTask();

    init_task.execute(db);

}

public class InitTask extends AsyncTask<DBAdapter,String, Void> {

    String TABLE_3;

    protected Void doInBackground(DBAdapter... db) {
        try {
            db[0].createDatabase();
            db[0].openDataBase();
            Cursor c = db[0].getCursor3(db[0].TABLE_3, user_id);

            String[] array=new String[2];
            viteza = new float[c.getCount()];
            time = new String[c.getCount()];

            if (c.moveToFirst()) {

                do {


                    publishProgress(c.getString(3),c.getString(4));
                    Thread.sleep(500);


                } while (c.moveToNext());

            }
            c.close();
            db[0].close();

        } catch (Exception e) {
            Log.d("Eroare", "doInBackground", e);
        }

        return null;
    }

    protected void onProgressUpdate(String...values) {

        Aitem items[] = new Aitem[1];

        viteza[contor]=Float.valueOf(values[0]);
        time[contor]=values[1];
        if(contor>3)
        {
        items[0]=new Aitem(Color.RED, "Evolution",viteza);
        lv.setTitle("Evolutia vitezei");

        lv.setAxisValueX(time);

        setContentView(lv);
        }
        contor++;
    }

}



}

我在这行得到错误:

I get error at this line:

viteza[contor]=Float.valueOf(values[0]);


java.lang.NumberFormatException: 
   at org.apache.harmony.luni.util.FloatingPointParser.parseFltImpl(Native Method)
 at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:321)

有没有人任何线索是什么gooing错???

Has anyone any clue what is gooing wrong???

编辑:

在我的愚见值[0] = c.getString(3)和值[1] = c.getString(4)左右....都是字符串......不是吗?

In my humble opinion values[0]=c.getString(3) and values[1]=c.getString(4) so ....are Strings...aren't they?

推荐答案

我不知道只要看一眼,但我可以告诉你,这就是Log.v是非常方便的。把Log.v(TAG,\\+值[] +\\),你会看到什么是越来越给这个函数。如果这是任何其他比纯数字,那会是什么导致发生异常。

I'm not sure just by looking at this, but I can tell you, this is where Log.v is extremely handy. Put a Log.v(TAG,"\""+values[]+"\""), and you'll see exactly what's getting to that function. If it's anything other than a pure number, that'd be what's causing the exception to occur.

这篇关于lang.NumberFormatException在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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