A Question And Answer Site
2013-12-25 11:52
429 查看
关于Fragment(XXFragment) not attached to Activity 异常
描述:出现该异常,是因为Fragment的还没有Attach到Activity时,调用了如getResource()等,需要上下文Content的函数。解决方法,就是等将调用的代码写在OnStart中。我此处是在Fragment 的 onCreateView() 中getResources().getStringArray(R.array.statistics_list);
解决:增加一个isAdded()判断
参考:http://stackoverflow.com/questions/6870325/android-compatibility-package-fragment-not-attached-to-activity
关于java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState异常
描述:在使用Fragment保存参数的时候,可能是因为需要保存的参数比较大或者比较多,这种情况下页会引起异常。Bundle b = new Bundle(); b.putParcelable("bitmap", bitmap2); imageRecognitionFragment.setArguments(b);设置好参数,并且添加hide(),add(),方法之后,需要commit(),来实现两个Fragment跳转的时候,这种情形下参数需要进行系统保存,但是这个时候你已经实现了跳转,系统参数却没有保存。就会报此异常。
解决:并不需要系统保存的参数,只要你自己设置的参数能够传递过去,在另外一个Fragment里能够顺利接受就行了,现在android里提供了另外一种形式的提交方式commitAllowingStateLoss(),从名字上就能看出,这种提交是允许状态值丢失的。到此问题得到完美解决,值的传递是你自己控制的。
关于tomcat启动,双击startup.bat时闪一下就没了
描述:用命令启动D:\>cd apache-tomcat-6.0.30\bin D:\apache-tomcat-6.0.30\bin>startup.bat
输出错误提示:
The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
解决:直接在catalina.bat中的 set CURRENT_DIR=%cd%后加入一行 set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13(因人而异,路径写死了)
关于使用AIDL服务时,经常会遇到AndroidRuntime: java.lang.SecurityException: nvocation to an incorrect interface这个错误
解决:服务端与客户端都要有相同的接口(使用到的),这里的“相同”是指完全相同,包括包名,也就是说要在不同工程下建立相同的包名。(我这里出现此错误,是没有AIDL文件所在的相同包名)。关于升级到 AppCompat v22.1.0 报错: AppCompat does not support the current theme features
描述:java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbarinstead.
解决:最新的Surpport里面的主题检查好像更严格了。以前使用Toolbar的时候,我是这么定义的
<style name="AppTheme.Base" parent="Theme.AppCompat.Light"> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> </style>
升级之后就出问题了
<style name="AppTheme.Base" parent="Theme.AppCompat.Light"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> </style>
其实最好的方法还是,不管在哪里,都使用sdk预置的主题
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> </style>
相关文章推荐
- The Project Management Question and Answer Book
- 《The Project Management Question and Answer Book》
- Top 10 Struts Interview Question And Answer - J2EE
- Interview: basic question and my answer
- The Project Management Question and Answer Book
- 论文笔记:Ask, Attend and Answer: Exploring Question-Guided Spatial Attention for Visual Question Answeri
- aspnet_Membership_ChangePasswordQuestionAndAnswer
- Question and Answer (Personal Use)
- Ask, Attend and Answer: Exploring Question-Guided Spatial Attention for Visual Question Answering
- poj 2371 questiong and answer
- Lesson8 First listen and then answer the question.
- Question and answer
- [Node.js]30. Level 6: Listen 'Question' from client, and then Answer the Question
- queryQuestionAndAnswer 接口
- Question and Answer
- MOSS 2007 Publishing web site definition template – onet.xml – syntax for properties and getting the right content types
- SharePoint Publishing Site Map Providers and Navigation
- 站点地图与权限:Sitemap and Role
- Exchange 2010 DAG local and Site DR/Failover and Fail back
- Differences between SPWeb.Users and SPWeb.SiteUsers