2

首先,我尝试了所有 java.lang.Stackoverflowerror 错误问题,但没有改变这个错误。为什么我收到此错误?

我的 ListeleActivity 课程是;

 package com.mobil.eposta;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.mail.Message;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class ListeleActivity extends Activity
{
    static List<String> gelen;
    static ListView listView;
    static ArrayList<String> konulist;
    static ArrayList<String> kimdenlist;
    static ArrayList<String> govdelist;
    static ArrayAdapter<String> arrayAdapter;
    static ArrayList<String> dosyaIsmi;
    static Message[] messageslist;
    static int messagePosition;
    static int onClickPosition;
    static boolean messageEkBulunuyormu;

    ArrayList<String> eklist;
    int clickKonum;
    static boolean ekvar;

    ListView lv;
    Button btnSave, btnClear;
    HashMap<Integer, Boolean> mCartItems = new HashMap<Integer, Boolean>();

    Baglanti baglantiNesnesi = new Baglanti();
//  EkDurumu ekdurumuNesnesi = new EkDurumu();
//  GoruntuleActivity goruntuleNesnesi = new GoruntuleActivity();

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listalt);

        konulist = (ArrayList<String>) baglantiNesnesi.getKonu();
        kimdenlist = (ArrayList<String>) baglantiNesnesi.getKimden();
        govdelist = (ArrayList<String>) baglantiNesnesi.getGovde();
        messageslist = baglantiNesnesi.messages;

        lv = (ListView) findViewById(R.id.list);
        LayoutInflater mLInflater = getLayoutInflater();
        final ListViewAdapter adapter = new ListViewAdapter(getApplicationContext(),
                kimdenlist, konulist, mLInflater);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick( AdapterView<?> parent, View item, 
                                       int position, long id) 
              {
                    final Intent intent = new Intent(ListeleActivity.this, GoruntuleActivity.class);
                    startActivity(intent);
                    onClickPosition = position;
                    Toast.makeText(ListeleActivity.this, "Bastın", Toast.LENGTH_SHORT).show();
              }
            });
    }
}

我的 GoruntuleActivity.class 是;

public class GoruntuleActivity extends Activity
{
    ListeleActivity listeleNesnesi = new ListeleActivity();

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.epostagoruntuleme);
         }
}


   05-07 17:24:32.796: E/AndroidRuntime(728): FATAL EXCEPTION: main
05-07 17:24:32.796: E/AndroidRuntime(728): java.lang.StackOverflowError
05-07 17:24:32.796: E/AndroidRuntime(728):  at java.lang.Thread.currentThread(Thread.java:588)
05-07 17:24:32.796: E/AndroidRuntime(728):  at java.lang.ThreadLocal.get(ThreadLocal.java:59)
05-07 17:24:32.796: E/AndroidRuntime(728):  at android.os.Looper.myLooper(Looper.java:137)
05-07 17:24:32.796: E/AndroidRuntime(728):  at android.os.Handler.<init>(Handler.java:119)
05-07 17:24:32.796: E/AndroidRuntime(728):  at android.app.Activity.<init>(Activity.java:679)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:23)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.java:25)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.ListeleActivity.<init>(ListeleActivity.java:48)
05-07 17:24:32.796: E/AndroidRuntime(728):  at com.mobil.eposta.GoruntuleActivity.<init>(GoruntuleActivity.ja
05-07 17:24:33.006: D/dalvikvm(728): GC_FOR_MALLOC freed 3074 objects / 569272 bytes in 124ms
05-07 17:29:33.127: I/Process(728): Sending signal. PID: 728 SIG: 9

显现

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mobil.eposta"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MobilEpostaUygActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <activity android:name=".ListeleActivity"/>
         <activity android:name=".GoruntuleActivity"/>
    </application>
     <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest>
4

1 回答 1

3

不要自己创建活动。这些行是不必要的(并导致您的堆栈溢出):

ListeleActivity listeleNesnesi = new ListeleActivity();

GoruntuleActivity goruntuleNesnesi = new GoruntuleActivity();

您无需调用活动的构造函数,而是通过创建一个 newIntent并将其传递给startActivity. 阅读这篇关于Android Fundamentals的文档以获得更多解释。

于 2012-05-07T17:44:40.770 回答