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

  • Home
  • SEARCH
  • 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 8136271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:42:35+00:00 2026-06-06T10:42:35+00:00

I have the following method which is called when the value Edit Class… is

  • 0

I have the following method which is called when the value “Edit Class…” is selected in a ListView.:

public void editClassOptionPressed(AdapterView<?> parent,int position,ArrayList<Class>classesArrayList){
    //The line below throws the null pointer exception
    parent.getChildAt(position).setBackgroundColor(Color.BLUE);
    Toast.makeText(getApplicationContext(), "Please Select Class To Edit...",Toast.LENGTH_LONG).show();
    setEditListener(classesArrayList, adapter);
}

This method is called by the following method, which is in turn called in my OnCreate method:

public void setDefaultListener(final ArrayList<Class>classesArrayList){
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if(position==(classesArrayList.size()-3)){
            Intent intent = new Intent(ClassView.this, AddNewClassView.class);
            startActivity(intent);
        }
        else if(position==(classesArrayList.size()-1)){
            deleteClassOptionPressed(parent,position);
        }
        else if(position==(classesArrayList.size()-2)){
            **editClassOptionPressed(parent, position, classesArrayList);** 
        }
        else{
            Intent intent = new Intent(ClassView.this, GradeView.class);
            intent.putExtra("selectedClassName",((TwoLineListItem)view).getText1().getText());
            startActivity(intent);
        }
      }
    });
}

From what I’ve debugged so far, it appears that the parent does not register a child at that location, although the parent itself is non-null. I should also point out that this happens only when I have over a certain number of items in the ListView. Anyone have any ideas? Here is the logcat output:

06-26 18:31:23.373: E/AndroidRuntime(1243): FATAL EXCEPTION: main
06-26 18:31:23.373: E/AndroidRuntime(1243): java.lang.NullPointerException
06-26 18:31:23.373: E/AndroidRuntime(1243): athellolistview.com.ClassView.editClassOptionPressed(ClassView.java:112)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at hellolistview.com.ClassView$4.onItemClick(ClassView.java:266)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.widget.AdapterView.performItemClick(AdapterView.java:292)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.widget.AbsListView$1.run(AbsListView.java:3168)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.os.Handler.handleCallback(Handler.java:605)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.os.Looper.loop(Looper.java:137)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at android.app.ActivityThread.main(ActivityThread.java:4424)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at java.lang.reflect.Method.invokeNative(Native Method)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at java.lang.reflect.Method.invoke(Method.java:511)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-26 18:31:23.373: E/AndroidRuntime(1243):     at dalvik.system.NativeStart.main(Native Method)
  • 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-06T10:42:39+00:00Added an answer on June 6, 2026 at 10:42 am

    position != childPosition

    Maybe you should consider using an ExpandableListView, which helps with this problem:

    int childPosition = ExpandableListView.getPackedPositionChild(position);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method called myMethod which maps to the following DWR method: List<MyObject>
I have this method Verify_X which is called during databind for a listbox selected
I have following method which I am using to load ActiveX control dynamically, Dim
I have the following method which serialises an object to a HTML tag. I
I have the following method which is not capturing anything from the user.If I
I have the following delegate method which is listening for when text changes in
I have a view with which I have a button calling the following method.
I have a CATiledLayer into which I render content in the following method -
I have the following code which is giving me a Method POST, Status (canceled)
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of

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.