我在运行应用程序时遇到了一些错误。我有一个java文件调用xml文件来膨胀片段。然而,当我运行它时,我有一个膨胀例外。我环顾四周,但没有解决方案似乎对我有用。代码能够在模拟器和一些真实设备上顺利运行,但是当我尝试在我的S3上运行时,会显示错误。我的java和xml文件如下所示
LoginFragment.java
package com.example.ray.cdmsv2.Fragments;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ray.cdmsv2.R;
public class LoginFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
return layoutInflater.inflate(R.layout.fragment_login,container,false);
}
}
fragment_login.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".Fragments.LoginFragment"
android:background="@color/white">
<LinearLayout
android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<!-- Logo -->
<TableRow
android:layout_gravity="center">
<!-- Spacer -->
<TextView
android:layout_weight="10"/>
<ImageView
android:id="@+id/imageViewFrontLogo"
android:layout_width="200dp"
android:layout_height="235dp"
android:src="@drawable/logo_simtech"
android:layout_weight="80"/>
<!-- Spacer -->
<TextView
android:layout_weight="10"/>
</TableRow>
</TableLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_username"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:layout_marginTop="0dp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_login"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/forgot_password_link"
style="@style/Blue_Font"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/forgot_password"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:clickable="true"
android:onClick="actionForgotPassword"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"/>
<Button
android:id="@+id/sign_in_button"
style="@style/Button_Background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/action_login_short"
android:textStyle="bold"
android:onClick="actionLogin"
android:layout_margin="5dp"/>
</LinearLayout>
我的LoginFragment.java是试图膨胀fragment_login的文件,但是当我尝试运行代码时,我显示以下错误
03-05 16:14:26.752 21537-21537/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ray.cdmsv2, PID: 21537
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ray.cdmsv2/com.example.ray.cdmsv2.Activities.MainActivity}: android.view.InflateException: Binary XML file line #53: Error inflating class android.support.design.widget.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class android.support.design.widget.TextInputLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.example.ray.cdmsv2.Fragments.LoginFragment.onCreateView(LoginFragment.java:16)
at android.app.Fragment.performCreateView(Fragment.java:2114)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.app.Activity.performStart(Activity.java:6328)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
非常感谢帮助