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 6690397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:37:56+00:00 2026-05-26T05:37:56+00:00

hy! I always get a NullPointerEx in my code. The list size is 7

  • 0

hy!

I always get a NullPointerEx in my code. The list size is 7 so this can’t be null. The customlistime exists. I have no idea where do i get the Exception. In my other programm this code worked.

Please help

Calling:

Log.e("SP",String.valueOf(list.size())); //List size is 7
ca = new CustomAdapter(this, R.layout.customlistitem, list); //global var
lv.setAdapter(ca); //Error Occurs here

CustomAdaptor:

public class CustomAdapter extends ArrayAdapter<SPEntry>{

    private ArrayList<SPEntry> entries;

    public CustomAdapter(Context context, int textViewResourceId,ArrayList<SPEntry> objects) {
        super(context, textViewResourceId, objects);
        this.entries = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = new ViewHolder();
        LayoutInflater li = (LayoutInflater)CustomAdapter.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = li.inflate(R.layout.customlistitem,null);
            holder.date = (TextView) convertView.findViewById(R.id.item_date);
            holder.lesson = (TextView) convertView.findViewById(R.id.item_lesson);
            holder.teacher = (TextView) convertView.findViewById(R.id.item_teacher);
            holder.image = (ImageView) convertView.findViewById(R.id.item_picture);
            convertView.setTag(holder);
        }
        else{
              holder = (ViewHolder) convertView.getTag();
        }
        holder.date.setText(entries.get(position).date);
        holder.teacher.setText(entries.get(position).teacher);
        holder.lesson.setText(entries.get(position).lesson);
        Bitmap bt = Bitmap.createScaledBitmap(entries.get(position).picture, 48, 48, false);
        holder.image.setImageBitmap(bt);
        return convertView;         
    } 

}

Viewholder:

public class ViewHolder {

    public ImageView image;
    public TextView date;
    public TextView lesson;
    public TextView teacher;



    ViewHolder()
    {
    }
}

ErrorCode:

10-17 20:49:39.481: ERROR/AndroidRuntime(2767): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}: java.lang.NullPointerException
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.os.Looper.loop(Looper.java:123)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.main(ActivityThread.java:4363)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at java.lang.reflect.Method.invokeNative(Native Method)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at java.lang.reflect.Method.invoke(Method.java:521)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at dalvik.system.NativeStart.main(Native Method)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767): Caused by: java.lang.NullPointerException
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.korn.supplierplan.view.LVEntries.onCreate(LVEntries.java:30)

Picture from ca in the debugger:

http://img7.imagebanana.com/img/alen3q0g/Unbenannts.png

  • 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-26T05:37:56+00:00Added an answer on May 26, 2026 at 5:37 am

    It’s not CustomAdapter problem. It’s your ListView object lv problem, clearly it is not initialized or not inflated from layout.

    In your layout XML file add a ListView and add this before set CustomAdapter to ListView

    ListView lv = (ListView)findViewById(R.id.lv_sp);
    
    ca = new CustomAdapter(this, R.layout.customlistitem, list); 
    lv.setAdapter(ca); 
    

    EDIT: updated code, try to clean project and run it again!

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

Sidebar

Related Questions

What's wrong with this code ? I always get a Object synchronization method was
What is wrong with this code below. I always get FALSE, meaning after compression,
I always get this OutOfMemoryException : System.OutOfMemoryException was not handled. Message=Exception of type 'System.OutOfMemoryException'
Why I always get WSAETIMEDOUT error in this code : var fUDPBuf: array [1..UdpPacketSize]
in this block of code my uiimageview always get nil.as a result the code
I don't like this code but I always get confused with threads so wanted
I always get values from the database directly to a control like this: Code-behind:
I always get this problem when I link forms in C#. Here's the code
why i always get userDetailDao exception null when executed : package com.springweb.service; import com.springweb.dao.UserDetailDao;
I always get this error when trying to compile my file with Boost::GIL PNG

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.