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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:46:59+00:00 2026-06-06T04:46:59+00:00

I’m setting up a simple list view with no real data being populated to

  • 0

I’m setting up a simple list view with no real data being populated to it yet. However, when trying to run to test I get a null pointer exception every time. I can’t figure out whats causing the problem. The error log complains about the setLayoutParams. Here is my code:

public class Groups extends Activity {

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.groups_listviews);

        ListView lView = (ListView)findViewById(R.id.list_view_1);
        lView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT, R.layout.groups_listviews_row));
        lView.setCacheColorHint(0);
        lView.setAdapter(null);
        lView.setOnItemClickListener(new OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
            }
        });
    }

Logcat:

06-20 11:03:27.044: D/dalvikvm(3641): GC_EXTERNAL_ALLOC freed 64K, 43% free 3080K/5379K, external 2357K/2773K, paused 81ms
06-20 11:03:28.388: D/dalvikvm(3641): GC_EXTERNAL_ALLOC freed 6K, 43% free 3096K/5379K, external 4457K/4816K, paused 28ms
06-20 11:03:28.442: D/AndroidRuntime(3641): Shutting down VM
06-20 11:03:28.442: W/dalvikvm(3641): threadid=1: thread exiting with uncaught exception (group=0x40018560)
06-20 11:03:28.442: E/AndroidRuntime(3641): FATAL EXCEPTION: main
06-20 11:03:28.442: E/AndroidRuntime(3641): java.lang.RuntimeException: Unable to start activity ComponentInfo{com/com.main.Groups}: java.lang.NullPointerException
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread.access$1500(ActivityThread.java:124)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.os.Looper.loop(Looper.java:130)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread.main(ActivityThread.java:3806)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at java.lang.reflect.Method.invokeNative(Native Method)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at java.lang.reflect.Method.invoke(Method.java:507)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at dalvik.system.NativeStart.main(Native Method)
06-20 11:03:28.442: E/AndroidRuntime(3641): Caused by: java.lang.NullPointerException
06-20 11:03:28.442: E/AndroidRuntime(3641):     at com.main.Groups.onCreate(Groups.java:23)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-20 11:03:28.442: E/AndroidRuntime(3641):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
06-20 11:03:28.442: E/AndroidRuntime(3641):     ... 11 more

Answer: I was accessing the listview of the incorrect layout file (list_view_1), thanks for all the help!

  • 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-06T04:47:01+00:00Added an answer on June 6, 2026 at 4:47 am

    if the error complains about the setLayoutParams, than usually it is the receiver of the method (aka the ListView) which is null.

    I would check if

    ListView lView = (ListView)findViewById(R.id.list_view_1);
    

    returns null.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.