Reputation: 6061
I have a ListView in an Activity and I am setting a custom adapter to the ListView.
Should my adapter class be:
private static class MyAdapter extends ArrayAdapter
or
private class MyAdapter extends ArrayAdapter
I guess it should make no difference as long as the adapter is enclosed within the activity reference but wanted to confirm that.
Upvotes: 12
Views: 3177
Reputation: 98501
Holding onto the context is fine from within an adapter if you are careful about how you use the adapter. Adapters are usually tied to the lifecycle of their Context (an Activity) so it's fine. Use a WeakReference only if it makes sense.
Upvotes: 17