InflateException:Bin file line #19:Error inflating class MyTextView

一、错误简介

为了实现TextView的跑马灯效果,我自己写了一个MyTextView的类继承TextView,结果在layout的XML页面调用的时候出现错误。

类结构图如下:

错误提示如下:

错误区域代码如下:

/textViewDemo1/res/layout/activity04.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_runHorseLamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="这是一段很长的威武霸气的滚动的实现跑马灯效果的一段逼格很高的很有含义和涵养的文字"
/>
<!--ellipsize是小数点的意思 marquee 这句话是添加滚动效果-->
<!-- 获取焦点之后才能滚动 --> 19 <MyTextView
20 android:id="@+id/tv_runHorseLamp1"
21 android:layout_width="match_parent"
22 android:layout_height="wrap_content"
23 android:ellipsize="marquee"
24 android:singleLine="true"
25 android:text="这是一段很长的威武霸气的滚动的实现跑马灯效果的一段逼格很高的很有含义和涵养的文字"
26 />
<EditText
android:id="@+id/et_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</EditText> </LinearLayout>
     <MyTextView
android:id="@+id/tv_runHorseLamp1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="这是一段很长的威武霸气的滚动的实现跑马灯效果的一段逼格很高的很有含义和涵养的文字"
/>

fry.MyTextView

 package fry;

 import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView; public class MyTextView extends TextView{ public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
} public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
} public MyTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
} @Override
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
} }

二、解决方法

InflateException:Bin file line #19:Error inflating class MyTextView

这句话的意思就是MyTextView类填充错误,

/textViewDemo1/res/layout/activity04.xml

     <MyTextView
android:id="@+id/tv_runHorseLamp1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="这是一段很长的威武霸气的滚动的实现跑马灯效果的一段逼格很高的很有含义和涵养的文字"
/>

可以看到我们使用的时候是直接用的类名,而在XML中引用类名要带上包名,

于是,我们把上述代码的第一行改成fry.MyTextView就对了

实现效果如下:

InflateException:Bin file line #19:Error inflating class MyTextView的更多相关文章

  1. Android项目部署时,发生AndroidRuntime:android.view.InflateException: Binary XML file line #168: Error inflating class错误

    这个错误也是让我纠结了一天,当时写的项目在安卓虚拟机上运行都很正常,于是当我部署到安卓手机上时,点击登陆按钮跳转到用户主界面的时候直接结束运行返回登陆界面.    当时,我仔细检查了一下自己的代码,并 ...

  2. 错误解决:android.view.InflateException: Binary XML file line #11: Error inflating class com.tony.timepicker.TimePicker

    今天在做项目开发时遇到这么一个错误,完整的错误提示信息如下: java.lang.RuntimeException: Unable to start activity ComponentInfo{co ...

  3. TextInputLayout低版本bug :“android.view.InflateException: Binary XML file line #6 : Error inflating class Textview”

    开发中用到TextInputLayout配合TextInputEdittext做输入框,在android7.0 android8.0手机上运行正常,在异步android5.0.2的手机上,点击输入框就 ...

  4. bug_ _图片_android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>

    =========== 1   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zgan.communit ...

  5. bug_ _ android.view.InflateException: Binary XML file line #2: Error inflating class <unknown

    ========= 5.0     android异常“android.view.InflateException: Binary XML file line # : Error inflating ...

  6. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L ...

  7. Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.design.widget.TabLayout,TableLayout引起页面崩溃

    在使用TableLayout的时候,运行引用程序直接Crash. FATAL EXCEPTION: main Process: com.edaixi.activity, PID: 9703 java. ...

  8. widget自定义控件【android.view.InflateException: Binary XML file line #2: Error inflating class...】

    此错误比较难定位,场景是这样的:在一个widget中使用了自定义控件,始终会报 android.view.InflateException: Binary XML file line #2: Erro ...

  9. "android.uid.systemandroid.view.InflateException: Binary XML file line #7: Error inflating class android.webkit.WebView

    在android源码中编译app通过,运行时出现错误: "android.uid.systemandroid.view.InflateException: Binary XML file l ...

随机推荐

  1. 安装Vmware ESX Server5.5 ——hardware virtualization is not a feature of the cpu or is not enabled in the BIOS

    Error信息: hardware virtualization is not a feature of the cpu or is not enabled in the BIOS 解决方案: F2进 ...

  2. WikiMedia system architecture

    w 前端  服务端 后端

  3. FW: Nginx模块开发入门

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  4. UIButton+Block

    UIButton的一个Category,使用block处理UIControlEvent事件,如常用的TouchUpInside等.代码非原创,也是从网上看到的,用到了实际项目中,目前还没发现什么问题. ...

  5. Java RTTI and Reflection

    Reference: Java编程思想 java 反射(Reflect) Java系列笔记(2) - Java RTTI和反射机制 Java Reflection in Action, 有空再补 -- ...

  6. selenium3.x的使用例子

    1.需要下载selenium的相关包以备工程调用. 2.工程中配置引用selenium的lib. selenium3.x中主要是根据webdriver进行浏览器的各种操作,可以完全模仿人工操作浏览器, ...

  7. 转!java web项目 build path 导入jar包,tomcat启动报错 找不到该类

    在eclipse集成tomcat开发java web项目时,引入的外部jar包,编译通过,但启动tomcat运行web时提示找不到jar包内的类,需要作如下配置,将jar包在部署到集成的tomcat环 ...

  8. 文件下载(StreamingHttpResponse流式输出)

    文件下载(StreamingHttpResponse流式输出) HttpResponse会直接使用迭代器对象,将迭代器对象的内容存储成字符串,然后返回给客户端,同时释放内存.可以当文件变大看出这是一个 ...

  9. Django - ModelForm组件

    一.ModelForm组件 这是一个神奇的组件,通过名字我们可以看出来,这个组件的功能就是把model和form组合起来,先来一个简单的例子来看一下这个东西怎么用:比如我们的数据库中有这样一张学生表, ...

  10. sql server dba之路

    转自:https://blog.csdn.net/dba_huangzj/article/details/7841441 在专职DBA工作一年过一个月以后,开通了CSDN的博客专栏,在第一篇文章中,我 ...