zoukankan      html  css  js  c++  java
  • 自定义控件的getChildCount

    我真的是一步一步走过来,看过来的代码。不是能力问题,而是他们用的,我没用过,我用的他们不用。然后一句一句的问为什么,然后一句一句的去想为什么。
    只有这样,才能慢慢的熟悉,东一榔头西一棒子,不是分模块再细分的去看,真的,想玩转它,没戏。趁现在,有时间,事情不多,赶紧熟悉代码,还有不要只自己看,多问。好了。

    当你的自定义view继承自viewgroup的时候,getChildCount()得到的就是它里面的view个数。比如:
    BookShelfMain 这个类的getChildCount就是2。因为你看里面包裹里两个。当然你也可以在代码里面add。

    <******.bookshelf.ui.BookShelfMain
                android:id="@+id/bookshelf_main_layout"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >
    
                <FrameLayout
                    android:id="@+id/layout_book_mall"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
    
                <include
                    android:id="@+id/main_bookshelf"
                    layout="@layout/bookshelf" />
            </******.bookshelf.ui.BookShelfMain>

    dispatchDraw 就是ondraw()方法里面调用的,绘制字view的。具体我也忘了,自己百度吧。重要的是知道了这个api的含义。

  • 相关阅读:
    HTTP协议详解
    如何编写出拥抱变化的代码
    Cookie ,Session
    Request 请求
    MySQL如何处理死锁
    如何优化冒泡排序
    java数据结构分析
    response响应
    Tomcat服务器
    HTTP协议
  • 原文地址:https://www.cnblogs.com/caoxinyu/p/10568727.html
Copyright © 2011-2022 走看看