Plokoon
Plokoon

Reputation: 125

Android - getSystemService error?

I have followed this tutorial to get my ListView populating data -- http://android.amberfog.com/?p=296.

But it only works if I subclass my custom list adapter (MyCustomAdapter) like the tutorial does. However I would like to put this in a separate class but when I try to I end up getting an error on this line below saying that "The method getSystemService(String) is undefined for the type MyCustomAdapter

      public MyCustomAdapter() {
        mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

Any ideas how I can get this working in its own class? Any help appreciated.

Upvotes: 4

Views: 6751

Answers (1)

Varun
Varun

Reputation: 33983

getSystemService can be called on the context. Get a handle to the context inside your adapter and you can do something like this:

mContext.getSystemService()

Upvotes: 7

Related Questions