致命异常:主/ android.view.InflateException [英] FATAL EXCEPTION: main / android.view.InflateException

查看:376
本文介绍了致命异常:主/ android.view.InflateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建我的应用程序一个ViewPager。进出口新的开发Android所以首先我尝试样本看它从网站。
当我尝试在模拟器它强制关闭运行它。我不知道为什么我的错误,我查了code很多时候并没有什么区别。

im trying to create a ViewPager for my app. Im new to android developing so first im trying a sample to look how it works from this site. When i try to run it in the emulator it force closes. I dont know why i get the error, i checked the code lot of times and there is no difference.

因此​​,作为code是一样的,在上面的链接,我只提供logcat的。

So as the code is the same as in the link above i only provide the logcat.

01-30 04:07:40.059: E/AndroidRuntime(3013): FATAL EXCEPTION: main
01-30 04:07:40.059: E/AndroidRuntime(3013): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testviewpager/com.testviewpager.TestViewPagerActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.viewpagerindicator.TitlePagePageIndicator
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.os.Looper.loop(Looper.java:123)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread.main(ActivityThread.java:3683)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at java.lang.reflect.Method.invokeNative(Native Method)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at java.lang.reflect.Method.invoke(Method.java:507)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at dalvik.system.NativeStart.main(Native Method)
01-30 04:07:40.059: E/AndroidRuntime(3013): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.viewpagerindicator.TitlePagePageIndicator
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.Activity.setContentView(Activity.java:1657)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at com.testviewpager.TestViewPagerActivity.onCreate(TestViewPagerActivity.java:14)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-30 04:07:40.059: E/AndroidRuntime(3013):     ... 11 more
01-30 04:07:40.059: E/AndroidRuntime(3013): Caused by: java.lang.ClassNotFoundException: com.viewpagerindicator.TitlePagePageIndicator in loader dalvik.system.PathClassLoader[/data/app/com.testviewpager-1.apk]
01-30 04:07:40.059: E/AndroidRuntime(3013):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
01-30 04:07:40.059: E/AndroidRuntime(3013):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
01-30 04:07:40.059: E/AndroidRuntime(3013):     ... 20 more

该com.viewpagerindicator是libary项目(链接其com.jakewharton.android.viewpagerindicator,我知道,我只是将其改为原来的),在那里,我什么都没有改变,从作者网站只进口。
因此,如果有人知道我做错了什么,请帮助。我可以提供详细信息,如果这还不够。

The com.viewpagerindicator is a libary project (on the link its com.jakewharton.android.viewpagerindicator, i know that, i just changed it to the original), there i changed nothing, only imported from the authors site. So if anyone know what i did wrong please help. I can provide more information if this is not enough.

推荐答案

我有同样的问题,但我想通了,解决办法很简单,如果你是以下的这个环节我一样你必须从你的主布局。参见删除这部分[jakewharton.android]这是什么造成inflateException并使它就像你的链接viewPagerIndicator主要布局库包名称

I have the same problem but i figured out that the solution very simple if you are following this link like me you have to delete this part [jakewharton.android] from your main layout refering to link main layout this what causing inflateException and make it just like what your viewPagerIndicator library package name

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" />
</LinearLayout>

这篇关于致命异常:主/ android.view.InflateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆