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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:37:33+00:00 2026-06-15T17:37:33+00:00

I am facing a problem , while calling the ListActivity I guess , it

  • 0

I am facing a problem , while calling the ListActivity I guess , it tells me that the system functions are not working before onCreate . I see that onCreate is called(according to my code), but it’s giving me an IllegalStateException, which I never dealt before with. By the way, I am using SherlockListActivity. Here’s my code :

    public class MenuActivity extends SherlockListActivity {
    ListView scroll;
    int time;       

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);         
        scroll = this.getListView();
        this.setListAdapter(new MyAdapter());           
    }


    public View find(int x){
        return findViewById(x);
    }


    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        switch (position){
        case (0):{
            Toast.makeText(getApplicationContext(), "Hello you just chose \"Splash\"", Toast.LENGTH_SHORT).show();
        }break;
        case (1):{
            Toast.makeText(getApplicationContext(), "Its another one here !", Toast.LENGTH_SHORT).show();
        }break;
        case (2):{
            Toast.makeText(getApplicationContext(), String.valueOf(id) +" and "+ position, Toast.LENGTH_SHORT).show();

        }break;
        }


    }

    public void showToast(String toast){
        Toast.makeText(getApplicationContext(), toast, Toast.LENGTH_SHORT).show();
    }



}

class MyAdapter extends ArrayAdapter<String>{       

    LayoutInflater inf = LayoutInflater.from(this.getContext());

    public MyAdapter() {
        super(new MenuActivity() , 0 ,stringArray);
        // TODO Auto-generated constructor stub
    }


    public static String[] stringArray= new String[]{"Splash"   , "Another Example" , "Future Checkable"};


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        if (convertView == null){
            inf.inflate(R.layout.normal_row, parent , false);
        }
        switch(position){
        case(0):
            convertView = (LinearLayout) inf.inflate(R.layout.row_switch, parent,false);

            break;
        }


        return super.getView(position, convertView, parent);
    }




}

And my Stack Trace :

    12-09 16:19:45.144: E/AndroidRuntime(28754): FATAL EXCEPTION: main
12-09 16:19:45.144: E/AndroidRuntime(28754): java.lang.RuntimeException: Unable to start activity ComponentInfo{seaskyways.testingproject/seaskyways.testingproject.MenuActivity}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.os.Looper.loop(Looper.java:137)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread.main(ActivityThread.java:5039)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at java.lang.reflect.Method.invokeNative(Native Method)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at java.lang.reflect.Method.invoke(Method.java:511)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at dalvik.system.NativeStart.main(Native Method)
12-09 16:19:45.144: E/AndroidRuntime(28754): Caused by: java.lang.IllegalStateException: System services not available to Activities before onCreate()
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.Activity.getSystemService(Activity.java:4463)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:128)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at seaskyways.testingproject.MyAdapter.<init>(MenuActivity.java:82)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at seaskyways.testingproject.MenuActivity.onCreate(MenuActivity.java:26)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.Activity.performCreate(Activity.java:5104)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-09 16:19:45.144: E/AndroidRuntime(28754):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-09 16:19:45.144: E/AndroidRuntime(28754):    ... 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-15T17:37:33+00:00Added an answer on June 15, 2026 at 5:37 pm

    Don’t instantiate a new Activity as the Context for your adapter, instead pass this where you instantiate the adapter instead:

    LayoutInflater inf; 
    
    public MyAdapter(Context context) {
        super(context, 0 ,stringArray);
        inf = LayoutInflater.from(context);
    }
    

    and in the MenuActivity‘s onCreate method:

    this.setListAdapter(new MyAdapter(this));
    

    Also, in your getView() method return the convertView and not the view return by the super call:

    return convertView;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a problem while deleting a record that is referenced by another table.
I'm facing a problem while unit testing my forms. The problem is that data
I am facing a problem while calling processRequest function from javascript. I need two
I'm facing a problem while working with iFrames. What I need to do is,
I am facing problem while calling the alert box. Can I know what is
I am facing problem while setting focus in EdiText. Below is my EditText property.
I am facing problem while generating CAB file. I want to customize the INF
i am using mvc 3 code first. facing problem while passing data form SecurityAttribute
I am facing a problem while creating a static cursor in DB2. This is
I am facing a problem while disabling the command button after one click. I

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.