在Api 10中的android.widget.TextView InflateException

时间:2014-09-29 15:56:54

标签: java android textview compatibility android-version

起初我不支持较低的Android版本。因为我不得不将minSdkVersion转换为Api 10。我一直收到错误(在布局代码下面)。我收录了android-support-v4.jar。据我所知,android.widget.textview正在使用Api10(我对其进行了测试)。究竟是什么导致了这一点。

错误:

android.view.InflateException: Binary XML file line #29: Error inflating class android.widget.TextView

附:它正在开发Api 16

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.myproject.LoginActivity" >

    <TextView
        android:id="@+id/loginTip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15sp"
        android:text="Log in!" />

    <EditText
        android:id="@+id/username"
        android:layout_width="fill_parent"
        android:layout_height="39sp"
        android:layout_above="@+id/password"
        android:layout_centerHorizontal="true"
        android:hint="@string/enter_email"
        android:text="" />

    <EditText
        android:id="@+id/password"
        android:layout_width="fill_parent"
        android:layout_height="39sp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:hint="@string/enter_password"
        android:inputType="textPassword"
        android:text="" />

    <Button
        android:id="@+id/loginButton"
        android:layout_width="150sp"
        android:layout_height="40sp"
        android:layout_alignRight="@+id/password"
        android:layout_below="@+id/password"
        android:layout_marginTop="10sp"
        android:background="@drawable/buttonshape"
        android:text="@string/login"
        android:textColor="#D1D1D1"
        android:textSize="25sp" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:contentDescription="@string/logotext"
        android:src="@drawable/logontext_old" />

</RelativeLayout>

logcat的

09-29 16:31:38.723: E/AndroidRuntime(588): FATAL EXCEPTION: main
09-29 16:31:38.723: E/AndroidRuntime(588): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myproject/com.myproject.LoginActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class android.widget.TextView
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.os.Looper.loop(Looper.java:130)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread.main(ActivityThread.java:3683)
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.reflect.Method.invokeNative(Native Method)
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.reflect.Method.invoke(Method.java:507)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-29 16:31:38.723: E/AndroidRuntime(588):  at dalvik.system.NativeStart.main(Native Method)
09-29 16:31:38.723: E/AndroidRuntime(588): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class android.widget.TextView
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2206)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2261)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.Activity.setContentView(Activity.java:1657)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.myproject.LoginActivity.onCreate(LoginActivity.java:61)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-29 16:31:38.723: E/AndroidRuntime(588):  ... 11 more
09-29 16:31:38.723: E/AndroidRuntime(588): Caused by: java.lang.reflect.InvocationTargetException
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-29 16:31:38.723: E/AndroidRuntime(588):  ... 25 more
09-29 16:31:38.723: E/AndroidRuntime(588): Caused by: java.lang.NumberFormatException: unable to parse '@2131034118' as integer
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.Integer.parse(Integer.java:383)
09-29 16:31:38.723: E/AndroidRuntime(588):  at java.lang.Integer.parseInt(Integer.java:372)
09-29 16:31:38.723: E/AndroidRuntime(588):  at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:122)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.content.res.TypedArray.getInt(TypedArray.java:254)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.widget.TextView.<init>(TextView.java:671)
09-29 16:31:38.723: E/AndroidRuntime(588):  at android.widget.TextView.<init>(TextView.java:343)
09-29 16:31:38.723: E/AndroidRuntime(588):  ... 28 more

0 个答案:

没有答案