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.
getSystemServicecan be called on the context. Get a handle to the context inside your adapter and you can do something like this: