做这样一个页面,下面有五个页签,滑动,有数据显示listview,无数据显示动画,开始我看到他们好多东西是相同的,就提取出来,用include包含布局文件:
结果报一下错误:
01-28 11:27:36.593: E/AndroidRuntime(16182): FATAL EXCEPTION: main
01-28 11:27:36.593: E/AndroidRuntime(16182): java.lang.StackOverflowError
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2666)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.widget.FrameLayout.draw(FrameLayout.java:450)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.widget.ScrollView.draw(ScrollView.java:1939)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.support.v4.view.ViewPager.draw(ViewPager.java:2171)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.draw(View.java:11100)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10536)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.View.getDisplayList(View.java:10534)
01-28 11:27:36.593: E/AndroidRuntime(16182): at android.view.ViewGroup.drawChild(ViewGroup.java:2864)
开始一直没找到原因,因为没有明确说哪里报错。那个类,那个控件之类的。后来发现是嵌套的层次太深了。一个xml里面包含include,里面的xml还包含include,后台勉为其难,都放到一个xml文件,就ok了!