2012-08-16 61 views
0

我有一個登錄活動崩潰與無效的活動佈局ID的應用程序的應用程序。有沒有其他人看到這個錯誤,因爲我瘋了。我在擴展RoboSherlockActivity的應用程序中有幾個類,但只有這個類導致崩潰。該活動是一個簡單的登錄頁面,包含兩個用於電子郵件和密碼的EditText以及一個提交按鈕,另一個按鈕可導致Facebook登錄。ActionBarSherlock應用程序崩潰在充氣一個類

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 

UPDATE

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

這條線是什麼?

android:scrollbars="?orientation_specific_scrollbars" 

除非這是我只是不熟悉的資源值的一些表示法,否則這是您的問題。 the scrollbars attribute的唯一有效值爲:

  • none「沒有滾動條顯示」。
  • horizontal「僅顯示水平滾動條」。
  • vertical「僅顯示垂直滾動條。」

您需要將其更改爲其中一個值。

+0

是的,那是問題所在。謝謝!!!將其更改爲垂直,應用程序不再崩潰。 orientation_specific_scrollbars是應用程序中定義的一種樣式,它在集成ActionBarSherlock之前一直運行:)。再次感謝。 – 2012-08-16 16:39:37

+0

沒問題。 :-) – kcoppock 2012-08-16 16:44:43

1

崩潰是

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

某處在你的XML你已經把2130772074,將其更改爲?數。

+0

它不在我的xml中,似乎是在應用程序中生成的ID,調試時,登錄的佈局ID不同:2130903190. – 2012-08-16 15:50:07

+0

發佈您遇到問題的XML。 – kcoppock 2012-08-16 15:51:20

+0

更新了最初的帖子 – 2012-08-16 15:58:24