为什么会发生 InflateException(由 ClassNotFoundException 引起)?

Why does an InflateException (Caused by ClassNotFoundException) occur?

我正在开发一个节拍器应用程序。我正在做让人们 select 节奏的部分。看起来像这样:

    Tempo:    <-- TextView
      90      <-- EditText
  --O------   <-- SeekBar

但是后来我改变了主意,把EditText改成了TextView。这是 xml:

的一部分
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center_horizontal">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="@dimen/all_text_size"
        android:text="@string/tempo_text"/>
    <TexView //This used to be an EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tempo_text"/>
    <SeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="270"
        android:id="@+id/tempo_seek"/>
</LinearLayout>

更改前,一切正常。但是在更改之后,tempo_text TextView 有一个警告说:

Element TextView is not allowed here

我很困惑,如果上面的 TextView 是允许的,为什么 不被允许?所以我忽略了警告,认为这只是 Android Studio 的错误之一。当我运行应用程序时,出现异常:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metronomewithvoice/com.themetronome.MainActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class TexView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
        at android.app.ActivityThread.access0(ActivityThread.java:150)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:5225)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class TexView
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
        at android.app.Activity.setContentView(Activity.java:1895)
        at com.themetronome.MainActivity.onCreate(MainActivity.java:15)
        at android.app.Activity.performCreate(Activity.java:5133)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
            at android.app.ActivityThread.access0(ActivityThread.java:150)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:5225)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
            at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.TexView" on path: DexPathList[[zip file "/data/app/com.metronomewithvoice-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.metronomewithvoice-2, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        at android.view.LayoutInflater.createView(LayoutInflater.java:559)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
            at android.app.Activity.setContentView(Activity.java:1895)
            at com.themetronome.MainActivity.onCreate(MainActivity.java:15)
            at android.app.Activity.performCreate(Activity.java:5133)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
            at android.app.ActivityThread.access0(ActivityThread.java:150)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:5225)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
            at dalvik.system.NativeStart.main(Native Method)

而且我确定我的 Java 代码没有问题,因为异常发生在 setContentView 行(MainActivity.java 第 15 行)。

请告诉我为什么会出现这个异常,以及如何解决它。

你打错了 TexView 应该是 TextView