关于android EditText报错

happyxlj 2012-03-11 09:43:00
unable to parse 'android.widget.EditText@4053d6f8' as integer
请问这是什么原因呀、

<EditText
android:layout_width="80dp"
android:layout_height="wrap_content"
android:id="@+id/internet"
android:text=""
android:password="true"
android:padding="3dip"
android:scrollHorizontally="true" />
我是这么写的
...全文
374 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
垚淼 2012-03-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 happyxlj 的回复:]
portI = Integer.parseInt(portS);这句话不能执行。。。
portI是一个int,portS是一个String。。这样不行么??
[/Quote]
portS输入数字时可以转,输入字符串时不能转
爬行的乌龟 2012-03-24
  • 打赏
  • 举报
回复
楼主是把字符串转换成整型吗?那就用Integer.valueOf(String )方法。
a_tuzi 2012-03-23
  • 打赏
  • 举报
回复
很 明显的类型转换失败,,,你要转换成一个Integer,但是你输入的不是Integer类型的。。。
闪电001 2012-03-13
  • 打赏
  • 举报
回复
portI = Integer.parseInt(portS);这句话不能执行。。。
字符形式的数字转成int是吧?
试试这个: Integer.valueOf(string);
面包你大爷 2012-03-13
  • 打赏
  • 举报
回复
100%是他的postS取值有问题,把你的postS代码帖上来,帮你分析
leehong2005 2012-03-13
  • 打赏
  • 举报
回复
你就写这么一个错误,谁能帮你分析呀。
至少要把代码上下文贴出来呀。
楼上说的对,NumberFormatException通常就是转换字符串到数据引起的问题。
danielinbiti 2012-03-11
  • 打赏
  • 举报
回复
肯定是portS值有问题,你看看赋值对不对把。
happyxlj 2012-03-11
  • 打赏
  • 举报
回复
portI = Integer.parseInt(portS);这句话不能执行。。。
portI是一个int,portS是一个String。。这样不行么??[Quote=引用 3 楼 danielinbiti 的回复:]

你activity的onCreate跟踪到哪行代码呢
[/Quote]
happyxlj 2012-03-11
  • 打赏
  • 举报
回复
portI = Integer.parseInt(portS);这句话不能执行。。。
portI是一个int,portS是一个String。。这样不行么??[Quote=引用 4 楼 w21fanfan 的回复:]

java.lang.NumberFormatException: unable to parse 'android.widget.EditText@4053ea60' as integer
好好看看这个异常......
[/Quote]
happyxlj 2012-03-11
  • 打赏
  • 举报
回复
portI = Integer.parseInt(portS);这句话不能执行。。。
portI是一个int,portS是一个String。。这样不行么??
w21fanfan 2012-03-11
  • 打赏
  • 举报
回复
java.lang.NumberFormatException: unable to parse 'android.widget.EditText@4053ea60' as integer
好好看看这个异常......
danielinbiti 2012-03-11
  • 打赏
  • 举报
回复
你activity的onCreate跟踪到哪行代码呢
happyxlj 2012-03-11
  • 打赏
  • 举报
回复
03-11 21:56:50.144: E/AndroidRuntime(2736): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tju.edu.cn/com.tju.edu.cn.Init}: java.lang.NumberFormatException: unable to parse 'android.widget.EditText@4053ea60' as integer
这个是报错。。。
danielinbiti 2012-03-11
  • 打赏
  • 举报
回复
放到布局中编译没错。
报错的是哪行错呢?

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧