在给类膨胀时ActionBarSherlock应用程序崩溃

时间:2012-08-16 15:24:15

标签: android actionbarsherlock inflate-exception

我有一个Login活动,该活动会使用无效的int崩溃应用程序以获取活动布局ID。因为我疯了,有没有其他人看到这个错误。我在应用程序中有几个类扩展了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

更新

login.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>

2 个答案:

答案 0 :(得分:2)

这条线是什么?

android:scrollbars="?orientation_specific_scrollbars" 

除非这是我不熟悉的资源价值的符号,否则这是你的问题。 the scrollbars attribute的唯一有效值为:

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

您需要将其更改为其中一个值。

答案 1 :(得分:1)

崩溃发生在

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

你的xml中的某个位置?2130772074,将其更改为数字。