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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:54:11+00:00 2026-06-04T00:54:11+00:00

I am getting NullPointerException on lv.setAdapter(adapter) . I don’t understand, I changed some codes

  • 0

I am getting NullPointerException on lv.setAdapter(adapter). I don’t understand, I changed some codes in Adapter but then I removed them. And then this exception is started.

In kimdenlistduzeltilmis : 4 value

enter image description here

In konulist : 4 value

enter image description here

final LayoutInflater mLInflater = getLayoutInflater();
        final ListViewAdapter adapter = new ListViewAdapter(
                getApplicationContext(), kimdenlistduzeltilmis, konulist,
                mLInflater);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View item,
                    int position, long id) {
                // adapter.Refresh();
                onClickPosition = position;
                try {
                    EkDurumu ekdurumuNesnesi = new EkDurumu();
                    ekdurumuNesnesi.MessagePositionEkBulunuyormu(
                            onClickPosition, goruntuleNesnesi.getMessages());

                } catch (Exception e) {
                    e.printStackTrace();
                }

And ListViewAdapter:

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class ListViewAdapter extends BaseAdapter {
    static HashMap<Integer, Boolean> cartItems = new HashMap<Integer, Boolean>();
    Context mContext;
    ArrayList<String> kimdenlist; // to load images
    ArrayList<String> konulist; // for data
//  ArrayList<String> imagelist;
    LayoutInflater mLayoutInflater;

    public ListViewAdapter(Context context, ArrayList<String> kimdenlist, ArrayList<String> konulist,
            LayoutInflater layoutInflater) {
        mContext = context;
        this.kimdenlist = kimdenlist;
        this.konulist = konulist;
        mLayoutInflater = layoutInflater;
    }

    @Override
    public int getCount() 
    {
        return konulist.size(); // images array length
    }

    @Override
    public Object getItem(int arg0) {

        return null;
    }

    @Override
    public long getItemId(int arg0) {

        return 0;
    }

    int count = 0;

    // customized Listview
    @Override
    public View getView(int position, View arg1, ViewGroup arg2) {

        View v;
        final int pos = position;
        v = mLayoutInflater.inflate(R.layout.listust, null);

        TextView kimden = (TextView) v.findViewById(R.id.textvKimden);
        kimden.setText(kimdenlist.get(position));
        TextView konu = (TextView) v.findViewById(R.id.textvKonu);
        konu.setText(konulist.get(position));

//      // saving check box state at the time of raloading
        CheckBox ch = (CheckBox) v.findViewById(R.id.chk);
        try {
            if (count != 0) {
                boolean b = cartItems.get(pos);
                if (b == false)
                    ch.setChecked(false);
                else
                    ch.setChecked(true);
            }
        } catch (NullPointerException e) {

        }


        ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                cartItems.put(pos, arg1);
                count++;

            }
        });
        return v;
    }

    public static HashMap<Integer, Boolean> getcartItems() {
        return cartItems;
    }

    public void Remove()
       {
        notifyDataSetChanged();
       }

}

And my Logcat:

05-16 16:13:12.962: E/AndroidRuntime(347): FATAL EXCEPTION: main
05-16 16:13:12.962: E/AndroidRuntime(347): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobil.eposta/com.mobil.eposta.ListeleActivity}: java.lang.NullPointerException
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.os.Looper.loop(Looper.java:123)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 16:13:12.962: E/AndroidRuntime(347):  at java.lang.reflect.Method.invokeNative(Native Method)
05-16 16:13:12.962: E/AndroidRuntime(347):  at java.lang.reflect.Method.invoke(Method.java:521)
05-16 16:13:12.962: E/AndroidRuntime(347):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-16 16:13:12.962: E/AndroidRuntime(347):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-16 16:13:12.962: E/AndroidRuntime(347):  at dalvik.system.NativeStart.main(Native Method)
05-16 16:13:12.962: E/AndroidRuntime(347): Caused by: java.lang.NullPointerException
05-16 16:13:12.962: E/AndroidRuntime(347):  at com.mobil.eposta.ListeleActivity.onCreate(ListeleActivity.java:109)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 16:13:12.962: E/AndroidRuntime(347):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-16 16:13:12.962: E/AndroidRuntime(347):  ... 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-04T00:54:14+00:00Added an answer on June 4, 2026 at 12:54 am

    Looks like your ListView is null. Try adding

    lv = (ListView) findViewById(R.id.whatever_id_you_gave_your_listview);
    

    before you call setAdapter()

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

Sidebar

Related Questions

I'm passing some data between two activities but I'm getting a NullPointerException where I
i keep getting NullPointerException on this line: SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this); i ran some
I have a about screen that has some buttons, but I keep getting NullPointerException
I'm extending JPanel to make a custom drawing panel, but am getting a NullPointerException
I keep getting this java.lang.NullPointerException on the line where mLoginButton's onClickListener is initiated. I
I am getting nullpointerexception, don't know what actually is causing it. I read from
I am getting a nullpointerexception error on this line btn10.setOnClickListener(this); this is the entire
I am getting a NullPointerException becauase of this LogCat message: 02-17 13:01:10.766: W/System.err(950): org.json.JSONException:
I am trying to Set Location but getting NullPointerException , i have Provided android.permission.ACCESS_COARSE_LOCATION
I have and image (img1.png) in my drawable-hdpi folder, but im getting NullPointerException(?) when

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.