Reputation: 1
I have an AbsListView in my project and I have a getView method which is defined like this:
public abstract View getView (int position, View convertView, ViewGroup parent) {}
Now, what's the correct way to find the parent AbsListView from within the getView() method?
Upvotes: 0
Views: 437
Reputation: 9450
(I assume you mean you have custom implementation of abstract AbsListView) :
public class MyCustomListView extends AbsListView {
Then in your adapter use parent
parameter of getView
to refer to your custom AbsListView, i.e. :
@Override
public View getView (int position, View convertView, ViewGroup parent) {
MyCustomListView list = (MyCustomListView) parent;
// do something
}
The idea of accessing your AdapterView from the adapter does not seem too good to me, you should normally use your adapter to manage the data, and supply your AdapterView with it.
Upvotes: 1