Specifically, I took the LunchList.java file and pulled the
RestaurantWrapper class out into a seperate java file and everything
is working fine (I'm up through the point of adding the tabs to the
project). When I tried to pull the RestaurantAdapter class out,
things broke. I was getting errors in reference to the model parameter
within the super method and the LayoutInflater wasn't happy either.
Is it good practice to separate classes into their own files? What do
I need to change to make the RestaurantAdapter class work as a
standalone java file?
Thanks,
Mike
That's a bit difficult to answer in the abstract.
> What do
> I need to change to make the RestaurantAdapter class work as a
> standalone java file?
RestaurantAdapter takes advantage of being an inner class to directly
call methods on the outer class (LunchList), such as
getLayoutInflater(). If you wish to make RestaurantAdapter its own
top-level class in its own file, you will need to convert all those calls.
Since the adapter base classes support getContext(), which should return
the Activity, you can convert things like:
getLayoutInflater(...)
to:
((Activity)getContext()).getLayoutInflater(...)
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Warescription: Three Android Books, Plus Updates, One Low Price!