嘿,我要显示列表视图的每个人
包com.example.ewa;

import java.util.ArrayList;
import java.util.Arrays;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        ListView lst = (ListView) findViewById(R.id.listView1);
        tesst obj = new tesst();
        tesst[] ooo = new tesst[100];
        for(int i=0;i<ooo.length-1;i++)
        {
            ooo[i]= new tesst();
        }
        ooo[0].abss="Mercury";
        ooo[1].abss="Venus";
        String[] ppp= new String[1];
        for(int i=0;i<=1;i++)
        {
            ppp[i]=(String)ooo[i].abss;
        }
        String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
                "Jupiter", "Saturn", "Uranus", "Neptune" };
        //ArrayList<String> planetList = new ArrayList<String>();
        //planetList.addAll(Arrays.asList(ppp));

        ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this,
                R.layout.simplerow, R.id.textView1, ppp);

        listAdapter.add(ppp[0]);
        listAdapter.add(ppp[1]);

        // Add more planets. If you passed a String[] instead of a List<String>
        // into the ArrayAdapter constructor, you must not add more items.
        // Otherwise an exception will occur.


        // Set the ArrayAdapter as the ListView's adapter.
        lst.setAdapter(listAdapter);

测试是一堂课
和错误
03-28 06:51:38.607: D/dalvikvm(1083): GC_FOR_ALLOC freed 39K, 4% free 2945K/3052K, paused 63ms, total 67ms
03-28 06:51:38.617: I/dalvikvm-heap(1083): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 06:51:38.687: D/dalvikvm(1083): GC_FOR_ALLOC freed 2K, 4% free 3563K/3676K, paused 61ms, total 61ms
03-28 06:51:39.067: D/AndroidRuntime(1083): Shutting down VM
03-28 06:51:39.067: W/dalvikvm(1083): threadid=1: thread exiting with uncaught exception (group=0xb3a37b90)
03-28 06:51:39.107: E/AndroidRuntime(1083): FATAL EXCEPTION: main
03-28 06:51:39.107: E/AndroidRuntime(1083): Process: com.example.ewa, PID: 1083
03-28 06:51:39.107: E/AndroidRuntime(1083): java.lang.NullPointerException
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.AbsListView.obtainView(AbsListView.java:2240)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.ListView.onMeasure(ListView.java:1175)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.View.measure(View.java:16458)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.RelativeLayout.measureChild(RelativeLayout.java:689)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:473)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.View.measure(View.java:16458)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.View.measure(View.java:16458)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.View.measure(View.java:16458)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2289)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.View.measure(View.java:16458)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1914)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1111)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1293)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.Choreographer.doFrame(Choreographer.java:532)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.os.Handler.handleCallback(Handler.java:733)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.os.Handler.dispatchMessage(Handler.java:95)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.os.Looper.loop(Looper.java:137)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at android.app.ActivityThread.main(ActivityThread.java:4998)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-28 06:51:39.107: E/AndroidRuntime(1083):     at dalvik.system.NativeStart.main(Native Method)
03-28 06:51:42.627: I/Process(1083): Sending signal. PID: 1083 SIG: 9
03-28 06:54:51.637: D/dalvikvm(1109): GC_FOR_ALLOC freed 42K, 4% free 2945K/3056K, paused 137ms, total 141ms
03-28 06:54:51.657: I/dalvikvm-heap(1109): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 06:54:51.807: D/dalvikvm(1109): GC_FOR_ALLOC freed 2K, 4% free 3563K/3680K, paused 144ms, total 144ms
03-28 06:54:52.507: D/AndroidRuntime(1109): Shutting down VM
03-28 06:54:52.507: W/dalvikvm(1109): threadid=1: thread exiting with uncaught exception (group=0xb3a37b90)
03-28 06:54:52.607: E/AndroidRuntime(1109): FATAL EXCEPTION: main
03-28 06:54:52.607: E/AndroidRuntime(1109): Process: com.example.ewa, PID: 1109
03-28 06:54:52.607: E/AndroidRuntime(1109): java.lang.NullPointerException
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.AbsListView.obtainView(AbsListView.java:2240)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.ListView.onMeasure(ListView.java:1175)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16458)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.RelativeLayout.measureChild(RelativeLayout.java:689)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:473)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16458)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16458)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16458)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2289)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16458)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1914)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1111)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1293)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.Choreographer.doFrame(Choreographer.java:532)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.os.Handler.handleCallback(Handler.java:733)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.os.Handler.dispatchMessage(Handler.java:95)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.os.Looper.loop(Looper.java:137)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at android.app.ActivityThread.main(ActivityThread.java:4998)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-28 06:54:52.607: E/AndroidRuntime(1109):     at dalvik.system.NativeStart.main(Native Method)
03-28 06:55:13.607: D/dalvikvm(1152): GC_FOR_ALLOC freed 46K, 4% free 2945K/3060K, paused 105ms, total 116ms
03-28 06:55:13.617: I/dalvikvm-heap(1152): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 06:55:13.917: D/dalvikvm(1152): GC_FOR_ALLOC freed 2K, 4% free 3563K/3684K, paused 145ms, total 145ms
03-28 06:55:15.007: I/Choreographer(1152): Skipped 153 frames!  The application may be doing too much work on its main thread.
03-28 06:55:15.217: D/gralloc_goldfish(1152): Emulator without GPU emulation detected.
03-28 06:55:18.467: I/Choreographer(1152): Skipped 37 frames!  The application may be doing too much work on its main thread.
03-28 06:55:19.507: I/Choreographer(1152): Skipped 43 frames!  The application may be doing too much work on its main thread.
03-28 06:59:27.297: D/dalvikvm(1200): GC_FOR_ALLOC freed 50K, 4% free 2945K/3064K, paused 119ms, total 120ms
03-28 06:59:27.337: I/dalvikvm-heap(1200): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 06:59:27.627: D/dalvikvm(1200): GC_FOR_ALLOC freed 0K, 4% free 3566K/3688K, paused 61ms, total 61ms
03-28 06:59:27.787: D/AndroidRuntime(1200): Shutting down VM
03-28 06:59:27.787: W/dalvikvm(1200): threadid=1: thread exiting with uncaught exception (group=0xb3a37b90)
03-28 06:59:27.857: E/AndroidRuntime(1200): FATAL EXCEPTION: main
03-28 06:59:27.857: E/AndroidRuntime(1200): Process: com.example.ewa, PID: 1200
03-28 06:59:27.857: E/AndroidRuntime(1200): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ewa/com.example.ewa.MainActivity}: java.lang.UnsupportedOperationException
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.os.Looper.loop(Looper.java:137)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread.main(ActivityThread.java:4998)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at dalvik.system.NativeStart.main(Native Method)
03-28 06:59:27.857: E/AndroidRuntime(1200): Caused by: java.lang.UnsupportedOperationException
03-28 06:59:27.857: E/AndroidRuntime(1200):     at java.util.AbstractList.add(AbstractList.java:404)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at java.util.AbstractList.add(AbstractList.java:425)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.widget.ArrayAdapter.add(ArrayAdapter.java:179)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at com.example.ewa.MainActivity.onCreate(MainActivity.java:46)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.Activity.performCreate(Activity.java:5243)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-28 06:59:27.857: E/AndroidRuntime(1200):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
03-28 06:59:27.857: E/AndroidRuntime(1200):     ... 11 more
03-28 06:59:32.717: I/Process(1200): Sending signal. PID: 1200 SIG: 9
03-28 07:00:27.967: D/dalvikvm(1254): GC_FOR_ALLOC freed 53K, 4% free 2945K/3068K, paused 64ms, total 67ms
03-28 07:00:27.987: I/dalvikvm-heap(1254): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 07:00:28.057: D/dalvikvm(1254): GC_FOR_ALLOC freed 2K, 4% free 3563K/3692K, paused 68ms, total 68ms
03-28 07:00:28.217: D/AndroidRuntime(1254): Shutting down VM
03-28 07:00:28.217: W/dalvikvm(1254): threadid=1: thread exiting with uncaught exception (group=0xb3a37b90)
03-28 07:00:28.257: E/AndroidRuntime(1254): FATAL EXCEPTION: main
03-28 07:00:28.257: E/AndroidRuntime(1254): Process: com.example.ewa, PID: 1254
03-28 07:00:28.257: E/AndroidRuntime(1254): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ewa/com.example.ewa.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.os.Looper.loop(Looper.java:137)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread.main(ActivityThread.java:4998)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at dalvik.system.NativeStart.main(Native Method)
03-28 07:00:28.257: E/AndroidRuntime(1254): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
03-28 07:00:28.257: E/AndroidRuntime(1254):     at com.example.ewa.MainActivity.onCreate(MainActivity.java:36)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.Activity.performCreate(Activity.java:5243)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-28 07:00:28.257: E/AndroidRuntime(1254):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
03-28 07:00:28.257: E/AndroidRuntime(1254):     ... 11 more
03-28 07:00:39.477: D/dalvikvm(1288): GC_FOR_ALLOC freed 57K, 5% free 2945K/3072K, paused 94ms, total 98ms
03-28 07:00:39.487: I/dalvikvm-heap(1288): Grow heap (frag case) to 3.545MB for 635812-byte allocation
03-28 07:00:39.547: D/dalvikvm(1288): GC_FOR_ALLOC freed 2K, 4% free 3563K/3696K, paused 56ms, total 56ms
03-28 07:00:39.747: D/AndroidRuntime(1288): Shutting down VM
03-28 07:00:39.747: W/dalvikvm(1288): threadid=1: thread exiting with uncaught exception (group=0xb3a37b90)
03-28 07:00:39.767: E/AndroidRuntime(1288): FATAL EXCEPTION: main
03-28 07:00:39.767: E/AndroidRuntime(1288): Process: com.example.ewa, PID: 1288
03-28 07:00:39.767: E/AndroidRuntime(1288): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ewa/com.example.ewa.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.os.Looper.loop(Looper.java:137)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread.main(ActivityThread.java:4998)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at dalvik.system.NativeStart.main(Native Method)
03-28 07:00:39.767: E/AndroidRuntime(1288): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
03-28 07:00:39.767: E/AndroidRuntime(1288):     at com.example.ewa.MainActivity.onCreate(MainActivity.java:36)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.Activity.performCreate(Activity.java:5243)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-28 07:00:39.767: E/AndroidRuntime(1288):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
03-28 07:00:39.767: E/AndroidRuntime(1288):     ... 11 more
03-28 07:05:37.197: I/Process(1288): Sending signal. PID: 1288 SIG: 9

如何解决,请帮帮我

最佳答案

嗨,我发现了什么问题。您的are数组声明错误。

更改此行:

String[] ppp= new String[2];


原因,在您的代码中

 String[] ppp= new String[1];
    for(int i=0;i<=1;i++)
    {
        ppp[i]=(String)ooo[i].abss;
    }


您正在创建大小为1的ppp数组。这意味着ppp [0]仅可用。
但是在for循环中,您尝试访问ppp [1]。

因此发生ArrayIndexOutOfBoundException。

关于java - 使用Android中的类将数据绑定(bind)到ListView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22711176/

10-09 01:44