java.lang.IllegalStateException: Could not execute method of the activity
2014-07-03 21:57
405 查看
如果编写程序时,大家遇到如下错误:
FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
java.lang.reflect.InvocationTargetException
java.lang.NullPointerException
那么向大家讲解一下我的解决办法:
一、在onCreate方法中setContentView(R.layout.activity_main);改为setContentView(R.layout.fragment_main);,
然后把if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}删掉,
再把除onCreate和你自己定义的方法外其他的全删掉,这样就可以了。
二、把fragment_main.xml文件中的所有内容覆盖activity_main.xml中的所有内容,
然后把if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}删掉,
再把除onCreate和你自己定义的方法外其他的全删掉,这样就可以了。
原因的话暂时还不清楚,估计是xml文件链接时出现了错误。
FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
java.lang.reflect.InvocationTargetException
java.lang.NullPointerException
那么向大家讲解一下我的解决办法:
一、在onCreate方法中setContentView(R.layout.activity_main);改为setContentView(R.layout.fragment_main);,
然后把if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}删掉,
再把除onCreate和你自己定义的方法外其他的全删掉,这样就可以了。
二、把fragment_main.xml文件中的所有内容覆盖activity_main.xml中的所有内容,
然后把if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}删掉,
再把除onCreate和你自己定义的方法外其他的全删掉,这样就可以了。
原因的话暂时还不清楚,估计是xml文件链接时出现了错误。
相关文章推荐
- java.lang.IllegalStateException: Could not execute method of the activity
- java.lang.IllegalStateException: Could not execute method of the activity
- Android 学习之异常总结--java.lang.IllegalStateException:Could not execute method of the activity
- java.lang.IllegalStateException: Could not find a method capture(View) in the activity class
- java.lang.IllegalStateException: Could not find a method onStartSingleInstanceActivityClickLisenter(
- Could not execute method of the activity Android
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification
- 解决Could not execute method of the activity
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receiv
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive
- 新增activity报错,Could not execute method of the activity
- java.lang.IllegalStateException: Could not find a method false(View) in the activity class com.xuan
- java.lang.IllegalStateException:The content of the adapter has changed but ListView did not receiv问题
- Could not execute method of the activity
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive
- java.lang.IllegalStateException:Make sure the content of your adapter is not modified from a backgro
- hbase java.lang.IllegalArgumentException: Could not resolve the DNS name of X.X.X.X:60020
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive
- java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method 解决办法