先贴上错误报告
01-25 04:23:03.493: E/AndroidRuntime(632): FATAL EXCEPTION: main
01-25 04:23:03.493: E/AndroidRuntime(632): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.justthere/com.justthere.view.ViewPagerActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.os.Handler.dispatchMessage(Handler.java:99)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.os.Looper.loop(Looper.java:123)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-25 04:23:03.493: E/AndroidRuntime(632): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 04:23:03.493: E/AndroidRuntime(632): at java.lang.reflect.Method.invoke(Method.java:507)
01-25 04:23:03.493: E/AndroidRuntime(632): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-25 04:23:03.493: E/AndroidRuntime(632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-25 04:23:03.493: E/AndroidRuntime(632): at dalvik.system.NativeStart.main(Native Method)
01-25 04:23:03.493: E/AndroidRuntime(632): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-25 04:23:03.493: E/AndroidRuntime(632): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-25 04:23:03.493: E/AndroidRuntime(632): at com.justthere.view.ViewPagerActivity.onCreate(ViewPagerActivity.java:57)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-25 04:23:03.493: E/AndroidRuntime(632): ... 11 more
01-25 04:23:03.493: E/AndroidRuntime(632): Caused by: java.lang.reflect.InvocationTargetException
01-25 04:23:03.493: E/AndroidRuntime(632): at java.lang.reflect.Constructor.constructNative(Native Method)
01-25 04:23:03.493: E/AndroidRuntime(632): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-25 04:23:03.493: E/AndroidRuntime(632): ... 19 more
01-25 04:23:03.493: E/AndroidRuntime(632): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-25 04:23:03.493: E/AndroidRuntime(632): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.content.res.Resources.loadDrawable(Resources.java:1709)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.View.<init>(View.java:1951)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.View.<init>(View.java:1899)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.view.ViewGroup.<init>(ViewGroup.java:286)
01-25 04:23:03.493: E/AndroidRuntime(632): at android.widget.LinearLayout.<init>(LinearLayout.java:120)
01-25 04:23:03.493: E/AndroidRuntime(632): ... 22 more
看着貌似很迷茫,因为一大串错误
不过事实上也就标记颜色的三行(当然我是以一个初学者的态度说只错了这三行)
告诉我可能是名字冲突,可是把整个工程的layout文件都看了一遍,都没发现有冲突的名字
然后注意到了蓝色那一行,具体内容对应如下:
view4 = lf.inflate(R.layout.layout4,null);
这股风其实也没有错
其实我一开始应该就注意到绿色文字那一行(可惜经验不足 啊),java.lang.OutOfMemoryError: bitmap size exceeds VM budget,什么意思呢,图片尺寸太大啊,所以到res下面的drawable改了图片尺寸就OK了,欣慰啊
总结如下:
1、名字冲突;
2、布局文件出错;
原文链接:https://www.f2er.com/xml/297311.html