InflateException:Bin file line #19:Error inflating class MyTextView
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的更多相关文章
- Android项目部署时,发生AndroidRuntime:android.view.InflateException: Binary XML file line #168: Error inflating class错误
这个错误也是让我纠结了一天,当时写的项目在安卓虚拟机上运行都很正常,于是当我部署到安卓手机上时,点击登陆按钮跳转到用户主界面的时候直接结束运行返回登陆界面. 当时,我仔细检查了一下自己的代码,并 ...
- 错误解决:android.view.InflateException: Binary XML file line #11: Error inflating class com.tony.timepicker.TimePicker
今天在做项目开发时遇到这么一个错误,完整的错误提示信息如下: java.lang.RuntimeException: Unable to start activity ComponentInfo{co ...
- TextInputLayout低版本bug :“android.view.InflateException: Binary XML file line #6 : Error inflating class Textview”
开发中用到TextInputLayout配合TextInputEdittext做输入框,在android7.0 android8.0手机上运行正常,在异步android5.0.2的手机上,点击输入框就 ...
- 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 ...
- 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 ...
- 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 ...
- 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. ...
- widget自定义控件【android.view.InflateException: Binary XML file line #2: Error inflating class...】
此错误比较难定位,场景是这样的:在一个widget中使用了自定义控件,始终会报 android.view.InflateException: Binary XML file line #2: Erro ...
- "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 ...
随机推荐
- Nginx-rtmp直播之业务流程分析 http://www.mamicode.com/info-detail-2287896.html
Nginx-rtmp直播之业务流程分析 http://www.mamicode.com/info-detail-2287896.html
- MAC OSX--docker
http://www.cnblogs.com/yjmyzz/p/docker-install-tutorial.html http://www.cnblogs.com/yjmyzz/p/docker- ...
- Eclipse 介绍
设置背景的插件: Darkest Dark Theme 添加 properties 插件: Properties Editor Git 插件: Egit 常用快捷键 command + 1 : 代码提 ...
- Linux ssh面密码登录
1.生成自己的公钥和私钥 ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa 进入~/.ssh目录看多了两个文件:id_rsa id_rsa.pub 其中一个是公钥一 ...
- Redis四(Set操作)
1.Set操作 Set集合就是不允许重复的列表 集合操作(无序) sadd(name,values) 1 # name对应的集合中添加元素 scard(name) 1 获取name对应的集合中元素个数 ...
- HBA 卡和RAID 卡
HBA卡: 只从HBA的英文解释HOST BUS ADAPTER(主机总线适配器)就能看出来,他肯定是给主机用的,一般HBA就是给主机插上后,给主机扩展出更多的接口,来连接外部的设备.大多数讲到HBA ...
- Delphi 正则表达式之TPerlRegEx 类的属性与方法(2): 关于子表达式
Delphi 正则表达式之TPerlRegEx 类的属性与方法(2): 关于子表达式 // MatchedExpression 与 SubExpressions[0] var reg: TPerl ...
- LeetCode:N叉树的层次遍历【429】
LeetCode:N叉树的层次遍历[429] 题目描述 给定一个 N 叉树,返回其节点值的层序遍历. (即从左到右,逐层遍历). 例如,给定一个 3叉树 : 返回其层序遍历: [ [1], [3,2, ...
- const修饰的常量 不能被直接修改 但是可以通过指针进行间接修改
大家都知道如下代码中,被const限定的a是不可以被直接修改的 void main() { const int a = 3; a=1; } 在C++中const修饰的常量,不能被直接修改,但是可以通过 ...
- Java结对编程之挑战出题
Java结对编程之挑战出题 需求分析 需求 对于挑战出题来说最主要的就是要产生的式子并将重复的式子去掉. 设计思路 具体的思路: 思路一: 原先我打算用集合中的元素的不重复性进行去重,这种思路的好处就 ...