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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:29:25+00:00 2026-06-05T11:29:25+00:00

My Activity class private String[] mStrings2={Title 01,Title 02}; private String[] mStrings = {Link to

  • 0

My Activity class

private String[] mStrings2={"Title 01","Title 02"};
private String[] mStrings = {"Link to the image1", "Link to the image2"};

MyAdapter adapter;

        mainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {              

            adapter=new LazyAdapter(this, mStrings, mStrings2);
            subList.setAdapter(adapternew);                       

        }
    });


MyAdapter class (MyAdapter.java)

    private Activity activity;
    private String[] data;
    private String[] data2;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 

//Constructor
public LazyAdapter(Activity a, String[] d, String[] mStrings2) {
        activity = a;
        data=d;
        data2=mStrings2;
        inflater = LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

When I click on the First List Item, I want to load elements in second Array. But when executing the code I’m getting “NullPointerException”. How to fix this. Pls guide me.

Edit….

    06-12 14:21:42.499: E/AndroidRuntime(1429): java.lang.NullPointerException
06-12 14:21:42.499: E/AndroidRuntime(1429):     at com.java.hotelapp.Item_List$1.onItemClick(Item_List.java:106)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.widget.AdapterView.performItemClick(AdapterView.java:282)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.widget.AbsListView.performItemClick(AbsListView.java:1037)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2449)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.widget.AbsListView$1.run(AbsListView.java:3073)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.os.Handler.handleCallback(Handler.java:587)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.os.Looper.loop(Looper.java:132)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at android.app.ActivityThread.main(ActivityThread.java:4123)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at java.lang.reflect.Method.invokeNative(Native Method)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at java.lang.reflect.Method.invoke(Method.java:491)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-12 14:21:42.499: E/AndroidRuntime(1429):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-12 14:21:42.499: E/AndroidRuntime(1429):     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-05T11:29:27+00:00Added an answer on June 5, 2026 at 11:29 am

    I can’t see the declaration of adapternew adapter so it could be null..

    subList.setAdapter(adapternew);         
    

    This line should be,

    adapter = new LazyAdapter(MyActivity.this, mStrings, mStrings2);
    subList.setAdapter(adapter);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class SoccerActivity extends Activity { private WebView webView; /** Called when the activity
public class SaveData extends Activity implements OnClickListener { private DataManipulator dh; static final int
I have an activity class file and an adapter class file. It will be
friends, i am using following global variables in my activity private String Session_ID; private
is it in general better to create AsyncTask as private class within an Activitiy,
I have Activity class, ListActivity class, TabActivity class. I want expand these classes using
I have a main activity class and find class. I need to access variable
I have an Activity class which has an attribute that references an AsyncTask instance
I have class A which extends the Activity class. This class is in package
I have a non-Activity class (let's call it NonActivity) that needs to post a

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.