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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:19:11+00:00 2026-06-17T02:19:11+00:00

I am trying to use array adapter to populate my listview. I build an

  • 0

I am trying to use array adapter to populate my listview. I build an array list of objects from POJO class to the array adapter. When i try to instantiate the arrayadapter class by passing the arraylist of objects, I am gettin null pointer exception while executing SETADAPTER line.

Please guide me to solve this

private void initialize() {     
    listView=(ListView)findViewById(R.id.lvOpenTicketList);

    POJO_Ticket pojo_Ticket; 
    ArrayList<POJO_Ticket> ticketArray  = new ArrayList<POJO_Ticket>(); 

     for(int i=0;i<openTicketList.size();i++){ 
        pojo_Ticket = new POJO_Ticket(openTicketList.get(i));
        ticketArray.add(pojo_Ticket);    
        Log.i("OpenTicket","i = " + Integer.toString(i)); 
     }
        Log.i("OpenTicket","ticketArray  " + ticketArray.size()); 


        adapterTicketList=new AdapterTicketList(this, ticketArray);
        listView.setAdapter(adapterTicketList);
        listView.setOnItemClickListener(this);    
}

public class AdapterTicketList extends ArrayAdapter<POJO_Ticket> {
Context context;
ArrayList<POJO_Ticket> ticketArray;
LayoutInflater vi;

public AdapterTicketList(Context context , ArrayList<POJO_Ticket> ticketArray) {    
    super(context, 0, ticketArray );    
    this.ticketArray = new ArrayList<POJO_Ticket>();    
    this.ticketArray.addAll(ticketArray);  
    this.context =context;
    Log.i("AdapterTicketList"," ticket id : " + ticketArray.get(0).getTicketObject().getId()); 
    vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
    }  

private class ViewHolder {
    TextView tvTicketID;  
    TextView tvCreationHour;  
    TextView tvTableNumber;  
    TextView tvAmount;    
    } 

public View getView(final int position, View convertView, ViewGroup parent) {      
    ViewHolder holder;    
    if (convertView == null) { 
        holder = new ViewHolder();                   
        convertView = vi.inflate(R.layout.rowticket,  null);  
        holder.tvTicketID = (TextView) convertView.findViewById(R.id.tvTicketID); 
        holder.tvCreationHour = (TextView) convertView.findViewById(R.id.tvCreationHour); 
        holder.tvTableNumber = (TextView) convertView.findViewById(R.id.tvTableNumber); 
        holder.tvAmount = (TextView) convertView.findViewById(R.id.tvQuantity);  
        convertView.setTag(holder); 
    } else {
        holder = (ViewHolder) convertView.getTag();  
    }       
    Log.i("AdapterTicketList"," ticket id : " + ticketArray.get(position).getTicketObject().getId()); 
    holder.tvTicketID.setText(ticketArray.get(position).getTicketObject().getId()) ;  
    holder.tvCreationHour.setText(ticketArray.get(position).getTicketObject().getCreationHour()) ;  
    holder.tvTableNumber.setText(ticketArray.get(position).getTicketObject().getTableNumber()) ;   
    holder.tvAmount.setText(Double.toString(ticketArray.get(position).getTicketObject().getTotalAmount())) ; 
    return convertView; 
    } 

}

01-08 22:11:13.707: W/dalvikvm(7284): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
01-08 22:11:13.717: E/AndroidRuntime(7284): FATAL EXCEPTION: main
01-08 22:11:13.717: E/AndroidRuntime(7284): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.restaurent/com.example.restaurent.OpenTicketList}: java.lang.NullPointerException
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.os.Looper.loop(Looper.java:137)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread.main(ActivityThread.java:4441)
01-08 22:11:13.717: E/AndroidRuntime(7284): at java.lang.reflect.Method.invokeNative(Native Method)
01-08 22:11:13.717: E/AndroidRuntime(7284): at java.lang.reflect.Method.invoke(Method.java:511)
01-08 22:11:13.717: E/AndroidRuntime(7284): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-08 22:11:13.717: E/AndroidRuntime(7284): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-08 22:11:13.717: E/AndroidRuntime(7284): at dalvik.system.NativeStart.main(Native Method)
01-08 22:11:13.717: E/AndroidRuntime(7284): Caused by: java.lang.NullPointerException
01-08 22:11:13.717: E/AndroidRuntime(7284): at com.example.restaurent.OpenTicketList.initialize(OpenTicketList.java:67)
01-08 22:11:13.717: E/AndroidRuntime(7284): at com.example.restaurent.OpenTicketList.onCreate(OpenTicketList.java:48)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.Activity.performCreate(Activity.java:4465)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-08 22:11:13.717: E/AndroidRuntime(7284): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
01-08 22:11:13.717: E/AndroidRuntime(7284): ... 11 more
  • 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-06-17T02:19:14+00:00Added an answer on June 17, 2026 at 2:19 am
    Caused by: java.lang.NullPointerException
        at com.example.restaurent.OpenTicketList.initialize(OpenTicketList.java:67)
    

    A NullPointerException means that you are trying to reference a method or member from a null variable, in this case null.setAdapter().

    So that means your current layout does not have a ListView with the id lvOpenTicketList…

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

Sidebar

Related Questions

I'm trying to use array_filter on an array of objects, and using a public
I'm trying to use a foreach loop for an array of objects. Inside of
I am trying to use the following code to populate a ListView using a
I've been beating my head around trying to populate a ListView with data from
I am using an array list, a listView, and a custom simple adapter in
I have a ListView which is populated from a string-array resource. I'm trying to
I'm trying to populate a list of files, and I'm using a custom ArrayAdapter
I am trying to create and populate an array of objects with information returned
I'm trying to create a custom ArrayAdapter to use for my ListFragment . Right
I have been trying to use array_unique to remove duplicates from the search results

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.