Android之 运行时错误总结

No view found for id for fragment

java.lang.IllegalArgumentException: No view found for id 0x7f0e0097 (com.swm.newoxygen:id/hometab_project) for fragment ProjectFragment{7c7b890 #0 id=0x7f0e0097}
我的是在transaction.add(R.id.hometab_project, fragment).commit();
在commit之后布局文件还没有加载完,导致找不到这个容器R.id.hometab_project控件的ID

解决方案:新建一个线程,当这个FrameLayout控件已经添加到屏幕上的时候,在执行commit()方法.

new Thread(new Runnable() {
            @Override
            public void run() {
                while (!hometabFrameLayoutProject.isAttachedToWindow()) {
                }
               transaction.add(R.id.hometab_project, fragment).commit();
            }
        }).start();

The specified child already has a parent.

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
产生原因是在onCreateViewHolder 的inflate()的root参数填写parent
解决应该写为null

@Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            mView = LayoutInflater.from(getContext()).inflate(R.layout.item_my_head, parent);
            mHolder = new MyHeadHolder(mView);
            return mHolder;
        }

Error:warning: Ignoring InnerClasses attribute for an anonymous inner classError:(com.baidu.lbsa

方法超过64K 异常
解决 在你的APP build.gradle下面加上multiDexEnabled true

defaultConfig{
    multiDexEnabled true
}
// 加上compile 'com.android.support:multidex:1.0.0'
dependencies{
    compile 'com.android.support:multidex:1.0.0'
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容