Android Error: java.lang.IllegalStateException: Could not execute method of the activity

使用eclipse运行项目的过程中,出现如下问题:

但是主要的问题根源已做标记,从网上查阅资料:

java.lang.IllegalStateException: Could not excute method of the activity

在java环境和应用尚未处于某个方法的合法调用状态时,而调用改方法时,抛出该异常。

java.lang.NumberFormatException: Invalid int:"09a0ds" (错误源头,并数字类型)

字符串转换为数字异常

其实,通过第二个已经可以定位问题的所在了。接下来主要来简要的说明下java数据类型中String,Integer,int之间的相互转换:

(1) String -> Integer:  Integer.valueOf(str)

(2) String -> Int: Integer.valueOf(str).intValue()

(3) Integer -> String:

  Integer it = new Integer(10);

  String str = it.toString();

(4) int -> String:

  1. String s = String.valueOf(i);

  2. String s = Integer.toString(i);

(5) Integer ->int:  i.intValue()

(6) int -> Integer:    Integer it = new Integer(i);  

通过(5)(6)其实,已经可以看到 int与Integer 的区别来,但是还是简单的进行下总结,算是加深记忆吧。

int: 基本数据类型,直接存储数值,初始化为0

integer: 复杂数据类型,使用引用指向这个对象,因为初始化为null。且Integer是int的封装类。

参考于:

http://my.oschina.net/u/1861837/blog/335581?p={{currentPage+1}}

哎,扯远了,我这边的问题实质上是测试数据时,将int型变量写成了“09a0ds”,这是什么呀。

    

原文地址:https://www.cnblogs.com/SkyflyBird/p/4807726.html