0

我有一个登录活动,该活动使应用程序崩溃,活动布局 ID 的 int 无效。有没有其他人看到这个错误,因为我要疯了。我在应用程序中有几个扩展 RoboSherlockActivity 的类,但只有这个导致崩溃。该活动是一个简单的登录页面,其中包含两个用于电子邮件和密码的 EditText 以及一个提交按钮,以及另一个导致 Facebook 登录的按钮。

08-16 17:09:55.552: E/AndroidRuntime(31215): FATAL EXCEPTION: main
08-16 17:09:55.552: E/AndroidRuntime(31215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.activity.Login}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.os.Looper.loop(Looper.java:137)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread.main(ActivityThread.java:4424)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.reflect.Method.invokeNative(Native Method)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.reflect.Method.invoke(Method.java:511)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at dalvik.system.NativeStart.main(Native Method)
08-16 17:09:55.552: E/AndroidRuntime(31215): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.createView(LayoutInflater.java:606)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:218)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.myapp.activity.Login.onCreate(Login.java:71)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.Activity.performCreate(Activity.java:4465)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-16 17:09:55.552: E/AndroidRuntime(31215):    ... 11 more
08-16 17:09:55.552: E/AndroidRuntime(31215): Caused by: java.lang.reflect.InvocationTargetException
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.reflect.Constructor.constructNative(Native Method)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.LayoutInflater.createView(LayoutInflater.java:586)
08-16 17:09:55.552: E/AndroidRuntime(31215):    ... 24 more
08-16 17:09:55.552: E/AndroidRuntime(31215): Caused by: java.lang.NumberFormatException: Invalid int: "?2130772074"
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.Integer.invalidInt(Integer.java:138)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.Integer.parse(Integer.java:375)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at java.lang.Integer.parseInt(Integer.java:366)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.content.res.TypedArray.getInt(TypedArray.java:254)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.View.<init>(View.java:2942)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.view.ViewGroup.<init>(ViewGroup.java:385)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.widget.FrameLayout.<init>(FrameLayout.java:99)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.widget.ScrollView.<init>(ScrollView.java:152)
08-16 17:09:55.552: E/AndroidRuntime(31215):    at android.widget.ScrollView.<init>(ScrollView.java:148)
08-16 17:09:55.552: E/AndroidRuntime(31215):    ... 27 more

更新

登录.xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:scrollbars="?orientation_specific_scrollbars"
        >

    <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >

        <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="14dp"
                android:paddingRight="14dp"
                android:orientation="vertical"
                >

            <TextView
                    style="@style/header"
                    android:id="@+id/sign_in_prompt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sign_in"
                    />

            <AutoCompleteTextView
                    android:id="@+id/email"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="@string/email"
                    android:inputType="textEmailAddress"
                    />

            <EditText
                    android:id="@+id/password"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="@string/password"
                    android:password="true"
                    android:inputType="textPassword"
                    />

            <Button
                    android:id="@+id/submit"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/sign_in"
                    />

            <Button
                    android:id="@+id/fb_login"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/login_facebook"
                    />

        </LinearLayout>

    </FrameLayout>
</ScrollView>
4

2 回答 2

2

这条线是什么?

android:scrollbars="?orientation_specific_scrollbars" 

除非这是我不熟悉的资源值的某种符号,否则这是您的问题。scrollbars属性的唯一有效值是:

  • none“不显示滚动条。”
  • horizontal“仅显示水平滚动条。”
  • vertical“仅显示垂直滚动条。”

您需要将其更改为这些值之一。

于 2012-08-16T16:16:07.777 回答
1

崩溃发生在

java.lang.NumberFormatException: Invalid int: "?2130772074"

在您的 xml 中某处放置了?2130772074,将其更改为一个数字。

于 2012-08-16T15:27:13.860 回答