02-28 15:17:16.281: DEBUG/AndroidRuntime(391): Shutting down VM

02-28 15:17:16.281: WARN/dalvikvm(391): threadid=1: thread exiting with uncaught exception (group=0x4001d800)


02-28 15:17:16.372: ERROR/AndroidRuntime(391): FATAL EXCEPTION: main


02-28 15:17:16.372: ERROR/AndroidRuntime(391): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.min.musicdemo/com.min.musicdemo.MusicDemo}: android.view.InflateException: Binary XML file line #255: Error inflating class com.min.musicdemo.lyric.LyricView


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.os.Handler.dispatchMessage(Handler.java:99)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.os.Looper.loop(Looper.java:123)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread.main(ActivityThread.java:4627)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at java.lang.reflect.Method.invokeNative(Native Method)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at java.lang.reflect.Method.invoke(Method.java:521)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at dalvik.system.NativeStart.main(Native Method)


02-28 15:17:16.372: ERROR/AndroidRuntime(391): Caused by: android.view.InflateException: Binary XML file line #255: Error inflating class com.min.musicdemo.lyric.LyricView


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.Activity.setContentView(Activity.java:1647)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at com.min.musicdemo.MusicDemo.onCreate(MusicDemo.java:255)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     ... 11 more


02-28 15:17:16.372: ERROR/AndroidRuntime(391): Caused by: java.lang.reflect.InvocationTargetException


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at com.min.musicdemo.lyric.LyricView.<init>(LyricView.java:39)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at java.lang.reflect.Constructor.constructNative(Native Method)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     ... 23 more


02-28 15:17:16.372: ERROR/AndroidRuntime(391): Caused by: java.lang.NullPointerException


02-28 15:17:16.372: ERROR/AndroidRuntime(391):     ... 27 more


02-28 15:17:16.421: WARN/ActivityManager(60):   Force finishing activity com.min.musicdemo/.MusicDemo


02-28 15:17:16.942: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44035078 com.min.musicdemo/.MusicDemo}


02-28 15:17:27.986: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{44035078 com.min.musicdemo/.MusicDemo}


02-28 15:21:17.266: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol

xml中使用

XML/HTML code

 

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!-- VIEW3 ********* lyric area -->
        
<
LinearLayout 
xmlns:android
=
"http://schemas.android.com/apk/res/android"
            
android:id
=
"@+id/llLyric"
            
android:orientation
=
"vertical"
           
android:layout_width
=
"fill_parent"
            
android:layout_height
=
"fill_parent" 
            
android:visibility
=
"gone"
            
android:layout_weight
=
"1"
            
            
<
TextView
                
android:id
=
"@+id/tvLyricTitle" 
                
android:layout_width
=
"fill_parent" 
                
android:layout_height
=
"wrap_content"
                
android:paddingLeft
=
"4dip"
                
android:text
=
"动感歌词"
                
android:textColor
=
"#0000FF"
                 
android:layout_gravity
=
"center_horizontal"
                
android:gravity
=
"center"
                
/>
            
<
com.min.musicdemo.lyric.LyricView
                
android:id
=
"@+id/lyricView" 
                
android:layout_width
=
"fill_parent" 
                
android:layout_height
=
"200dip"
                
/>
        
</
LinearLayout

类定义

Java code

 

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public 
class 
LyricView 
extends 
View {
    
private 
static 
final 
String TAG = 
"LyricView"
     
    
private 
Paint paint;
    
private 
Rect rect;                
// 歌词显示区域
    
private 
List<Sentence> list = 
null
;    
// 歌词list
    
private 
String text = 
"Lyric is loading..."
;           
// 单行歌词
    
private 
long 
currentTime = 
0
;        
// 正在演唱的时间
    
private 
int 
color = 
0xFF0000FF
;   
// 歌词颜色
     
    
public 
LyricView(Context context) {
        
super
(context);
 
        
// 生成paint    
        
paint = 
new 
Paint();
        
rect.left = 
this
.getLeft();
        
rect.top = 
this
.getTop();
        
rect.right = 
this
.getRight();
        
rect.bottom = 
this
.getBottom();
    
}
     
    
public 
LyricView(Context context, AttributeSet attrs) {
// 构造方法;根据需要实现继承自View的方法   
        
super
(context, attrs);
         
        
// 生成paint    
        
paint = 
new 
Paint();
        
rect.left = 
10
;
        
rect.top = 
50
;
        
rect.right = 
10
;
        
rect.bottom = 
50
;
         
        
//对于我们自定义的类中,我们需要使用一个名为obtainStyledAttributes的方法来获取我们的定义。   
        
//得到自定义控件的属性值。   
    
}


靠,原来是在构造函数中忘了创建rect对象
加上rect = new Rect();就ok了





自定义View编译失败。Binary XML file line #255: Error inflating的更多相关文章

  1. 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 ...

  2. "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 ...

  3. 异常 ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang.test.MyView

    发现自定义view时出现ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang. ...

  4. 错误:android.view.InflateException: Binary XML file line #167: Binary XML file line #167: Error inflating class <unknown>

    1:错误日志 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.8.activity.RecordActiv ...

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

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

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

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

  7. 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 ...

  8. 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 ...

  9. 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. ...

随机推荐

  1. web前端-html学习笔记

    学习html最重要的是坚持.细心.多动手.慕课网<HTML+CSS基础课程>的笔记. 1.<h1>网站标题</h1> 如:<h1>腾讯网</h1& ...

  2. Follow your heart

    世界上最可怕的两个词,一个是执着,一个是认真.认真的人改变自己,执着的人改变命运.任何时候都别怕重来,每个看似低的起点,都是通往高峰的必经之路.不用抱怨那些不尽如人意,问问自己,你够努力了吗?转自人民 ...

  3. CentOS rc.local 不执行的问题

    centos7 开机/etc/rc.local 不执行的问题 时间:2015-02-09 00:54来源:blog.51cto.com 作者:“闲潭小筑” 博客, 举报 点击:次 最近发现centos ...

  4. J2SE知识点摘记(二十五)

    Set 1.5.1        概述 Java 中的Set和正好和数学上直观的集(set)的概念是相同的.Set最大的特性就是不允许在其中存放的元素是重复的.根据这个特点,我们就可以使用Set 这个 ...

  5. 可以把一堆dll文件放到程序目录下的一个自建目录里面

    窦宁波大哥哥的那篇文章的这种写法还是很有参考价值的. QString strLibPath(QDir::toNativeSeparators(QApplication::applicationDirP ...

  6. (9)Xamarin测试账号申请与续用

    原文 Xamarin测试账号申请与续用 在Xamarin网站上可以申请30天试用的测试账号.试用期内,Xamarin会提供完整的功能试用. 30天试用时间到期后,在Visual Studio里面你加载 ...

  7. 交通银行万事达Y-POWER信用卡 普卡

    签账消费 免息尽享 失卡保护 风险全无 密码签名 任选 境外使用 本币还款 国内海外 环球支持 适合人群:年轻一族 发行状态:发行中     年费: 140元 币种: 人民币+美元 免年费政策:免首年 ...

  8. iOS6和iOS7代码的适配(4)——tableView

    iOS7上不少控件的样子有了变化(毕竟要扁平化嘛),不过感觉变化最大的肯定非tableView莫属.因为这个控件的高度可定制性,原先是使用及其广泛的,这样的一个改变自然也影响颇大. 1.accesso ...

  9. poj2017简单题

    #include <stdio.h> #include <stdlib.h> int main() { int n,i; while(scanf("%d", ...

  10. c# 搭建服务端 传输协议(2)

    在网络的数据传输中,要将需要传输的数据转换为二进制数据后传输,才能被服务端正常的接收,socket传输中,接收到的数据都会被放入byte[]中存放,所以在数据发送前,对二进制的数组进行有规律的排序,才 ...