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 ...
随机推荐
- Oracle重做日志REDO
什么是重做? 重做日志包含所有数据产生的历史改变记录. 重做日志目的是保证数据的安全,如果数据因特殊原因没有写到磁盘上,可以通过重做日志来恢复. 重做日志文件通常用于 恢复(实例恢复和介质恢复) 日志 ...
- python 里面的单下划线与双下划线的区别(私有和保护)
Python 用下划线作为变量前缀和后缀指定特殊变量. _xxx 不能用'from moduleimport *'导入 __xxx__ 系统定义名字 __xxx 类中的私有变量名 核心风格:避免用下划 ...
- 深入理解CNI
1.为什么会有CNI? CNI是Container Network Interface的缩写,简单地说,就是一个标准的,通用的接口.已知我们现在有各种各样的容器平台:docker,kubernetes ...
- JSP--JSP语法--指令---九大隐式对象--四大域对象--JSP内置标签--JavaBean的动作元素--MVC三层架构
一.JSP 原理:JSP其实就是一个servlet. Servlet负责业务逻辑处理,JSP只负责显示.开发中,JSP中不能有一行JAVA代码 二.JSP语法 1. JSP模板元素:JSP中HTML标 ...
- 神经网络中的数据预处理方法 Data Preprocessing
0.Principal component analysis (PCA) Principal component analysis (PCA) is a statistical procedure t ...
- SCSS入门
1. CSS预处理器 定义了一种新的专门的编程语言,编译后成正常的CSS文件.为CSS增加一些编程的特性,无需考虑浏览器的兼容问题,让CSS更加简洁,适应性更强,可读性更佳,更易于代码的维护等诸多好处 ...
- html-2, a img ul li ol dl dt dd 标签与列表标签的简单使用
<!-- a: a{ /*清除a标签的下划线*/ text-decoration: none; } (1)超链接 href 超链接的地址 target: _self 默认 在当前中打开链接地 ...
- POJ_2533 Longest Ordered Subsequence【DP】【最长上升子序列】
POJ_2533 Longest Ordered Subsequence[DP][最长递增子序列] Longest Ordered Subsequence Time Limit: 2000MS Mem ...
- Linux网络性能评估工具iperf 、CHARIOT测试网络吞吐量
网络性能评估主要是监测网络带宽的使用率,将网络带宽利用最大化是保证网络性能的基础,但是由于网络设计不合理.网络存在安全漏洞等原因,都会导致网络带宽利用率不高.要找到网络带宽利用率不高的原因,就需要对网 ...
- Spring 之 @ComponentScan以及mock Spring MVC
[ @ComponentScan] 纠正:可以成功 Autowired 的原因是我在另外一个 config 文件中扫描了根包,这会顺带扫描所有该包的子包 还有,,上面的写法容易出错,建议这样写, @C ...