且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误/AndroidRuntime(335):引起:java.lang.NullPointerException

更新时间:2023-11-19 13:48:28

取消注释此行

setContentView(R.layout.places);

已编辑:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:padding="6dip">
    <ListView android:id="@android:id/list" android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

将其替换为您的文件(Places.xml)

replace this with your file(Places.xml)

更新

 public void onCreate(Bundle savedInstance) {
        super.onCreate(savedInstance);
        //setContentView(R.layout.places);
        getallLocs();
        setListAdapter(new ArrayAdapter<Fields>(this,android.R.layout.simple_list_item_1, results));
//        displayLocs();

    }
    private void displayLocs() {
        lv = (ListView)findViewById(R.id.listPlaces);
        lv.setAdapter(new StudentListAdapter(this, R.layout.placeslist, results));

        //lv.setAdapter(new ArrayAdapter<Fields>(this,android.R.layout.simple_list_item_1, results));

    }