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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:21:24+00:00 2026-06-07T03:21:24+00:00

I have designed an android application where, I want to view a menu after

  • 0

I have designed an android application where, I want to view a menu after the splash screen. I trigger it correctly and I use an ArrayAdapter to create a custom ListView. but, when I run the module, it closes after the splash and the logcat indicate a NullPointerException. but, I have not done anything wrong as I knw. please help me out! 🙂

Thank You.

Code:

package com.sliit.droidman.main;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.sliit.droidman.R;

public class MainActivity extends Activity implements OnItemClickListener{

ArrayList<String> Methods = new ArrayList<String>();
ArrayList<String> MethodDiscription = new ArrayList<String>();
ArrayList<Integer> Icons = new ArrayList<Integer>();
ArrayList<Object> Objects = new ArrayList<Object>();

private ListItemAdapter adapter;
ListView lv;

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    Toast.makeText(
            this,
            "Title => " + Methods.get(position) + "=> n Description"
                    + MethodDiscription.get(position), Toast.LENGTH_SHORT).show();
}


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu);

    lv = (ListView) findViewById(R.layout.main_menu);
    fillArrayList();
    lv.setOnItemClickListener(this);

}

public void RefreshListView() {
    Objects.clear();
    for (int i = 0; i < Methods.size(); i++) {
        Object obj = new Object();
        Objects.add(obj);
    }
    Log.d("object array", "" + Objects.size());
    adapter = new ListItemAdapter(Objects, 1);
    lv.setAdapter(adapter);
}

private class ListItemAdapter extends ArrayAdapter<Object>{
    ViewHolder HolderView;

    public ListItemAdapter(List<Object> Item, int ID) {
        super(MainActivity.this, R.layout.listitem_row , Item);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflator = getLayoutInflater();
        convertView = inflator.inflate(R.layout.listitem_row, null);

        HolderView = new ViewHolder();
        HolderView.AppEvent = (TextView) convertView.findViewById(R.id.Event);
        HolderView.EventDisc = (TextView) convertView.findViewById(R.id.EventDescription);
        HolderView.iv = (ImageView) convertView.findViewById(R.id.avatar);

        convertView.setTag(HolderView);

        HolderView.AppEvent.setText(Methods.get(position));
        HolderView.EventDisc.setText(MethodDiscription.get(position));
        HolderView.iv.setBackgroundResource(Icons.get(position));

        return convertView;
    }

    private class ViewHolder {
        TextView AppEvent;
        TextView EventDisc;
        ImageView iv;

    }
}

public void fillArrayList() {
    Methods.clear();
    MethodDiscription.clear();
    Icons.clear();

    Methods.add(0,"Applications");
    Methods.add(1,"System Resources");
    Methods.add(2,"Statistics");
    Methods.add(3,"Threats");

    MethodDiscription.add(0, "bla bla bla");
    MethodDiscription.add(1, "bla bla bla");
    MethodDiscription.add(2, "bla bla bla");
    MethodDiscription.add(3, "bla bla bla");

    Icons.add(0, R.drawable.ic_launcher);
    Icons.add(1, R.drawable.ic_launcher);
    Icons.add(2, R.drawable.ic_launcher);
    Icons.add(3, R.drawable.ic_launcher);
}

}

The logCat from the place where the error occurred:

07-05 01:44:50.678: W/dalvikvm(1907): threadid=1: thread exiting with uncaught             exception (group=0x40a13300)
07-05 01:44:50.728: E/AndroidRuntime(1907): FATAL EXCEPTION: main
07-05 01:44:50.728: E/AndroidRuntime(1907): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sliit.droidman/com.sliit.droidman.main.MainActivity}:         java.lang.NullPointerException
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.os.Looper.loop(Looper.java:137)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread.main(ActivityThread.java:4745)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at java.lang.reflect.Method.invokeNative(Native Method)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at java.lang.reflect.Method.invoke(Method.java:511)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at dalvik.system.NativeStart.main(Native Method)
07-05 01:44:50.728: E/AndroidRuntime(1907): Caused by: java.lang.NullPointerException
07-05 01:44:50.728: E/AndroidRuntime(1907):     at com.sliit.droidman.main.MainActivity.onCreate(MainActivity.java:47)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.Activity.performCreate(Activity.java:5008)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-05 01:44:50.728: E/AndroidRuntime(1907):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-05 01:44:50.728: E/AndroidRuntime(1907):     ... 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-07T03:21:26+00:00Added an answer on June 7, 2026 at 3:21 am

    The lv variable will be null as you don’t search for its id, so instead of:

    lv = (ListView) findViewById(R.layout.main_menu);
    

    you should search for the ListView‘s id:

    lv = (ListView) findViewById(R.id.the_id_of_the_listview);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed application in Android and designed one splash screen image of size
I have designed the screen using this relative layout. <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
I want to create an Application with tabs, and I have found this guide
I have designed a main menu in android, but now I have no idea
I am developing an android contacts based application.I have designed the views.I am in
I have an text reader app that is designed to receive intent from Android
I have designed a menu that consists of a few buttons in several different
I have designed a new web site. I have hosted it online. I want
I have designed one sign-up form,in this form after getting all necessary values I
Is there any sample? I have my android application and I need to connect

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.