zoukankan      html  css  js  c++  java
  • 错误提示:java.lang.IllegalArgumentException: Only TabItem instances can be added to TabLayout.

    问题描述:在安卓模拟上运行程序时,一打开就报错:xx has stopped.

    解决办法:根据错误提示java.lang.IllegalArgumentException: Only TabItem instances can be added to TabLayout.    

    查看MainActivity.java代码中  setContentView(R.layout.activity_main);  ,直接去看activity_main.xml 的内容,发现 ViewPager 写在了 TabLayout 里。

    提示中明确说到: layout内部不可以放其他东西,只能放tabItem。

    改完之后的代码:

    <android.support.design.widget.TabLayout
    android:id="@+id/mTabLayout"
    android:background="@color/colorPrimary"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/colorAccent"
    app:tabMode="fixed"
    app:tabSelectedTextColor="@color/colorAccent"
    app:tabTextColor="@android:color/white"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
    android:id="@+id/mViewPager"
    android:layout_weight="1"
    android:layout_width="match_parent"
    android:layout_height="0dp">

    </android.support.v4.view.ViewPager>

    结果:已解决
  • 相关阅读:
    python 字符串前面加u,r,b的含义
    文本检测: CTPN
    ocr 识别 github 源码
    python 中写hive 脚本
    Win10 环境安装tesseract-ocr 4.00并配置环境变量
    OCR 识别原理
    pandas set_index和reset_index的用法
    整理 pandas 常用函数
    js es6 map 与 原生对象区别
    js 暂时性死区
  • 原文地址:https://www.cnblogs.com/insist8089/p/7148669.html
Copyright © 2011-2022 走看看