Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6573623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:09:25+00:00 2026-05-25T15:09:25+00:00

I keep getting this error: Unable to start activity ComponentInfo{com.Nostradamus/com.Nostradamus.Contactenlijst}: java.lang.NullPointerException And I don’t

  • 0

I keep getting this error:

Unable to start activity ComponentInfo{com.Nostradamus/com.Nostradamus.Contactenlijst}: java.lang.NullPointerException

And I don’t know what I do wrong.
It has something to do with the last code:
lv.setAdapter(new SimpleAdapter(this, mylist, R.layout.list_item, from, to));

This is my java code:

public class Contactenlijst extends Activity {
ListView lv;
@Override


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] from = new String[] {"voornaam", "achternaam", "geboortedatum", "adres", "postcode", "woonplaats", "email", "telefoon"};
    int[] to = new int[]{R.id.voornaam, R.id.achternaam, R.id.geboortedatum, R.id.adres, R.id.postcode, R.id.woonplaats, R.id.email, R.id.telefoon};

    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
    Log.d("test","test2");
    // Get the data (see above)
    JSONObject json = Database
            .getJSONfromURL("http://fabian.nostradamus.nu/Android/getcontactinfo.php");
    Log.d("test","test3");
    try {
        JSONArray contactinfo = json.getJSONArray("contactlijst");
        Log.d("test","test4");
        // Loop the Array
        for (int i = 0; i < contactinfo.length(); i++) {
            HashMap<String, String> map = new HashMap<String, String>();
            JSONObject e = contactinfo.getJSONObject(i);
            map.put("voornaam", e.getString("staff_name"));
            map.put("achternaam", e.getString("staff_lastname"));
            map.put("geboortedatum", e.getString("staff_dateofbirth"));
            map.put("adres", e.getString("staff_address"));
            map.put("postcode", e.getString("staff_address_postal"));
            map.put("woonplaats", e.getString("staff_address_city"));
            map.put("email", e.getString("staff_email"));
            map.put("telefoon", e.getString("staff_phone"));
            mylist.add(map);

            Log.e("test",map.toString());
        }
    } catch (JSONException e) {
        Log.e("log_tag", "Error parsing data " + e.toString());
    }

    lv = (ListView) findViewById(R.id.list);
    lv.setAdapter(new SimpleAdapter(this, mylist, R.layout.list_item, from, to));

}

}

And these are my xmls:

Contactenlijst

<?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"> 
<TextView android:id="@+id/voornaam"
     android:layout_width="50dip"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/achternaam"
     android:layout_width="70dip"
     android:layout_height="wrap_content" android:layout_weight="1"/>

 <TextView android:id="@+id/geboortedatum"
     android:layout_width="60dip"
     android:layout_height="wrap_content"  android:layout_weight="1"/>

 <TextView android:id="@+id/adres"
     android:layout_width="50dip"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/postcode"
     android:layout_width="70dip"
     android:layout_height="wrap_content" android:layout_weight="1"/>

 <TextView android:id="@+id/woonplaats"
     android:layout_width="60dip"
     android:layout_height="wrap_content"  android:layout_weight="1"/>

 <TextView android:id="@+id/email"
     android:layout_width="60dip"
     android:layout_height="wrap_content"  android:layout_weight="1"/>

 <TextView android:id="@+id/telefoon"
     android:layout_width="60dip"
     android:layout_height="wrap_content"  android:layout_weight="1"/>

Contactview

<?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">  

<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:drawSelectorOnTop="false"/>

<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No data">
</TextView>

</LinearLayout>

and Listitem

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:09:25+00:00Added an answer on May 25, 2026 at 3:09 pm

    you didn’t set the layout using

    setContentView(R.layout.yourlayout);
    

    so without add layout you are using your listview that’s why you getting NullPointerException.

    add this above line after

    super.onCreate(savedInstanceState);
    

    or before the use listview object

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this when trying to start a new project ERROR: Unable to
I keep getting this error randomly: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request.
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I keep getting this error when I try to commit a group of executed
I keep getting this error when I try to call Find() public void findTxt(string
I keep getting this error all over the place where I only have jquery
I keep getting this error whenever I call gethostbyname() in my C code. ==7983==
I keep getting this error, although the file still gets moved into the correct
I keep getting this error in Matlab: Attempted to access r(0,0); index must be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.