2016-05-30 154 views
0

我正在開發應用程序,我試圖通過Intent從「MainActivity」啓動一個名爲「PensionStatusActivity」的Activity。應用程序崩潰java.lang.stackOverflow異常

這是MainActivity中的調用行。

startActivity(new Intent(MainActivity.this, PensionStatusActivity.class)); 

PensionStatusActivity活性填充一個XML作爲它的佈局,其是作爲..

activity_pension_status.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:padding="2sp" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:id="@+id/llGo" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_marginTop="5sp" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5sp" 
      android:paddingLeft="10sp" 
      android:background="#D4D8D1" 
      android:textColor="#332C2F" 
      android:textStyle="bold" 
      android:text="@string/button_pension_status"/> 

     <EditText 
      android:id="@+id/etSamagraIdStatus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/et_back" 
      android:paddingLeft="10sp" 
      android:imeActionLabel="Done" 
      android:singleLine="true" 
      android:inputType="number" 
      android:maxLength="9" 
      android:layout_marginTop="20sp" 
      android:hint="Samagra ID"/> 
     <Button 
      android:id="@+id/btnGetStatus" 
      android:layout_height="40sp" 
      android:layout_width="wrap_content" 
      android:background="@drawable/button_go" 
      android:textColor="#FFFFFF" 
      android:layout_marginTop="10sp" 
      android:text="स्थिति देखें "/> 


      <!--Table View--> 
      <TableLayout 
       android:id="@+id/tlMemberProfile" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:padding="3sp" 
       android:background="#D8D8D8" 
       android:layout_marginTop="5sp"> 

       <TableRow 
        style="@style/trSchemesDetail"> 
        <TextView 
         style="@style/tvSchemeDetailTable" 
         android:text="Name"/> 
        <TextView 
         android:id="@+id/tvName" 
         style="@style/tvSchemeDetailTable" 
         /> 
       </TableRow> 
       <TableRow 
        style="@style/trSchemesDetail"> 
        <TextView 
         style="@style/tvSchemeDetailTable" 
         android:text="Gender"/> 
        <TextView 
         android:id="@+id/tvGender" 
         style="@style/tvSchemeDetailTable" 
         /> 
       </TableRow> 
       <TableRow 
        style="@style/trSchemesDetail"> 
        <TextView 
         style="@style/tvSchemeDetailTable" 
         android:text="Date Of Birth"/> 
        <TextView 
         android:id="@+id/tvDOB" 
         style="@style/tvSchemeDetailTable" 
         /> 
       </TableRow> 
      </TableLayout> 


     <ListView 
      android:id="@+id/lvPensionStatus" 
      android:layout_weight="1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 
    <include 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/footer"/> 

</LinearLayout> 
</LinearLayout> 

在PensionStatusActivity我已經使用下面線填充上面的XML。

setContentView(R.layout.activity_pension_status); 

我的問題是當控制過來這個填充線應用程序崩潰。與Samsung Galexy Tab 4.4 Android OS上的java.lang.stackOverFlowException。雖然與其他設備優良運行..

日誌如下

java.lang.StackOverflowError 
    at java.lang.ref.FinalizerReference.<init>(FinalizerReference.java:42) 
    at java.lang.ref.FinalizerReference.add(FinalizerReference.java:54) 
    at android.content.res.XmlBlock$Parser.<init>(XmlBlock.java:79) 
    at android.content.res.XmlBlock.newParser(XmlBlock.java:72) 
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:3707) 
    at android.content.res.Resources.loadDrawable(Resources.java:3440) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930) 
    at android.content.res.Resources.loadDrawable(Resources.java:3442) 
    at android.content.res.Resources.getDrawable(Resources.java:1924) 
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:990) 
    at android.gr 

請幫忙什麼是錯的。

在此先感謝..

+0

看起來像你recursivly調用一個方法'doIt方法() {doIt();}'這將導致一個StackOverFlowException(無法看到它是哪種方法,所以我解釋它使用虛擬方法'doIt()') –

+0

檢查此http://stackoverflow.com/questions/17481445/how-do-i-fix -a-java-lang-stackoverflow-exception?rq = 1 –

+0

嘿Chirag,謝謝你的回覆,問題已經解決了.. –

回答

2

根據stacktrace,這是您的可繪製資源中的循環引用。嘗試執行以下操作:

  1. 將佈局中的所有子項目註釋掉。
  2. 運行螞蟻測試。應用程序應該工作
  3. 取消註釋一個子視圖
  4. 運行和測試。如果沒事,到3點。如果沒有,最後添加視圖包含給破了資源的引用
  5. 通過檢查發現視圖中使用的所有繪圖資源
+0

嗨德米特里,謝謝你,我按照你的建議做了同樣的事情並解決問題。謝謝.. –

相關問題