0

我无法弄清楚是什么导致了这个线程错误。这是我的代码。我注释掉了几乎所有的代码,它仍然无法工作:

package com.dd.relay;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class MainActivity extends ListActivity {
    public final static String EXTRA_MESSAGE = "com.dd.relay.MESSAGE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

             // We'll define a custom screen layout here (the one shown above), but
             // typically, you could just use the standard ListActivity layout.
             setContentView(R.layout.activity_main);
             //ListView lv = (ListView)this.findViewById(R.id.relaylist);

          // Make a GET request for data
            /* String url = "http://localhost.com/contacts";
             String res = null;
             try {
                HttpRequest request = new HttpRequest();
                request.execute(new URL(url));

                Log.v(EXTRA_MESSAGE, res);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

             // Now create a new list adapter bound to the cursor.
             // SimpleListAdapter is designed for binding to a Cursor.
             String[] from = new String[] {"First", "Last", "Number"};
             int[] to = new int[] {R.id.first, R.id.last, R.id.number};


            // Create list for contacts
             List<Map<String, String>> data = new ArrayList<Map<String, String>>();
             Map<String, String> temp = new HashMap<String, String>();

             int id = 0;
             while(id<10)
             {
             RelayContact contact = new RelayContact("Matt", "Hintzke", "2062259311", id);
             temp.put("First",contact.first);
             temp.put("Last", contact.last);
             temp.put("Number", contact.num);

             data.add(temp);
             id++;
             }



             ListAdapter adapter = new SimpleAdapter(this, data, R.layout.list, from, to);  // Parallel array of which template objects to bind to those columns.

             // Bind to our new adapter.

             lv.setAdapter(adapter);
             */
            // CharSequence msg = "List loaded";
            // Context context = this.getApplicationContext();
             //Toast mytoast = Toast.makeText(context,  msg, Toast.LENGTH_LONG);
             //mytoast.show();
}

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }




}

这是来自控制台的错误

[2013-07-20 19:18:36 - ddms] null
java.lang.NullPointerException
    at org.eclipse.debug.internal.ui.DebugUIPlugin.launchInBackground(DebugUIPlugin.java:1286)
    at org.eclipse.debug.ui.DebugUITools.launch(DebugUITools.java:753)
    at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.debugRunningApp(AndroidLaunchController.java:176)
    at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.clientChanged(AndroidLaunchController.java:1733)
    at com.android.ddmlib.AndroidDebugBridge.clientChanged(AndroidDebugBridge.java:912)
    at com.android.ddmlib.Device.update(Device.java:591)
    at com.android.ddmlib.Client.update(Client.java:868)
    at com.android.ddmlib.HandleWait.handleWAIT(HandleWait.java:88)
    at com.android.ddmlib.HandleWait.handleChunk(HandleWait.java:66)
    at com.android.ddmlib.MonitorThread.callHandler(MonitorThread.java:414)
    at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:322)
    at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
4

0 回答 0