• 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));

  • 相关阅读:
    浅谈异或运算^的作用
    牛客网剑指offer第40题——数组中只出现一次的数字(浅谈位运算的妙用)
    归并排序——一文吃透归并和递归的思想和完整过程!(没看懂请留言)
    深入分析二分查找及其变体
    vector构造函数的学习
    牛客网剑指offer第34题——找到第一个只出现一次的字符
    牛客网剑指offer第27题——求字符串的全排列
    牛客网剑指offer第20题——定义栈的数据结构
    C++重载运算简介
    Leetcode中字符串总结
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/2995936.html
Copyright © 2020-2023  润新知