zoukankan      html  css  js  c++  java
  • Listview addHeaderView添加view报错

    04-02 16:55:31.153: E/AndroidRuntime(4874): Uncaught handler: thread main exiting due to uncaught exception
    04-02 16:55:31.163: E/Monkey(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied)
    04-02 16:55:31.243: E/AndroidRuntime(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied)
    04-02 16:55:31.243: E/AndroidRuntime(4874): FATAL EXCEPTION: main
    04-02 16:55:31.243: E/AndroidRuntime(4874): java.lang.ClassCastException: android.widget.AbsListView$LayoutParams
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1303)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1250)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:281)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:303)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.measure(View.java:8342)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.ListView.setupChild(ListView.java:1821)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.ListView.makeAndAddView(ListView.java:1748)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.ListView.fillDown(ListView.java:670)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.ListView.fillFromTop(ListView.java:727)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.ListView.layoutChildren(ListView.java:1598)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.AbsListView.onLayout(AbsListView.java:1260)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1520)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.View.layout(View.java:7204)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1142)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1876)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.os.Handler.dispatchMessage(Handler.java:99)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.os.Looper.loop(Looper.java:130)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at android.app.ActivityThread.main(ActivityThread.java:3683)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at java.lang.reflect.Method.invoke(Method.java:507)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
    04-02 16:55:31.243: E/AndroidRuntime(4874):     at dalvik.system.NativeStart.main(Native Method)
    04-02 16:55:31.253: E/AndroidRuntime(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied)

    java.lang.ClassCastException: android.widget.AbsListView$LayoutParams 

    意思类型转换错误

    subPager.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, 200)); // 这里的高绝对不能是WRAP_CONTENT

    原因我设置了LayoutParams

    就这一句代码搞了大半天

    我的父节点用的是RelativeLayout

    所以改为以下代码

    subPager.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,200));

  • 相关阅读:
    SQL Server 添加数据库没有权限等
    网站图片优化的重要性与技巧方案
    5年前端经验小伙伴教你纯css3实现饼状图
    css3 斜切角/斜边的实现方式来自BAT大神的出品
    Validate表单验证插件之常用参数介绍
    html实现邮箱发送邮件_js发送邮件至指定邮箱功能
    css重设样式_清除浏览器的默认样式
    大厂前端工程师教你如何使用css3绘制任意角度扇形+动画
    WordPress教程之如何批量删除未引用(无用)的TAG标签
    css引入的方式有哪些_四种css的引入方式与特点
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/2995936.html
Copyright © 2011-2022 走看看