酒吧code号太长的Integer.parseInt [英] Barcode Numbers too long for Integer.parseInt

查看:220
本文介绍了酒吧code号太长的Integer.parseInt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用棒code服务zbar和在某些数字应用shutsdown IM。

林扫描杆codeS,收到一个EditText酒吧code,有它设置所以它会搜索匹配ID的JSON数组。嗯,这正常的数字,整数扩大到。但是我有必要把它接受什么都看重它包含的方式正常工作。

使用断点像 000.000.000.0

也和 22-22ON 应用程序关闭。

有没有人对如何避免这种情况的线索?

是否有可能有它检查任何在类型化?

已经看过不同的片段和教程,但无法找到答案..

 字符串XYZ = edt.getText()的toString()。
            尝试{//获取JSON数组
                用户= json.getJSONArray(TAG_FIXTURE);
JSONObject的C = user.getJSONObject(的Integer.parseInt(XYZ)-1);


解决方案

的Integer.parseInt(价值)需要字符串只能包含数字。

如果你看看这里的海报有类似的问题。
<一href=\"http://stackoverflow.com/questions/2338790/get-int-from-string-also-containing-letters-in-java\">Get从字符串INT,还含有字母,在Java中

另外,您可以尝试使用简单的字符串,并尝试配合,如果有可能的ID,如22-22ON是你在搜索数据库present。

im using zbar for barcode services, and at certain numbers the app shutsdown.

Im scanning barcodes, receive the barcode in an edittext, have it set up so it would search the json array for matching id's. Well this works fine for normal numbers the way that Integers extend to.. However i have a need to have it accept what ever value it contains.

Also when using breakpoints like 000.000.000.0 and 22-22ON the app shuts down.

Does anyone have a clue on how to avoid this?

Is it possible to have it check for anything that is typed in?

Have looked at different snippets and tutorials, but cant find an answer..

     String xyz = edt.getText().toString();
            try {    // Getting JSON Array
                user = json.getJSONArray(TAG_FIXTURE);
JSONObject c = user.getJSONObject(Integer.parseInt(xyz)-1);

解决方案

Integer.parseInt(value) requires the String to only contain numbers.

If you look here the poster has a similar problem. Get int from String, also containing letters, in Java

Alternatively you could try simply using a String and try to match with that, if it is possible that the IDs like "22-22ON" are present in the database you're searching in.

这篇关于酒吧code号太长的Integer.parseInt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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