I have a question about the method getview in android.
My getview method(in the class QuestionsListAdapter
):
public View getView(int position, View convertView, ViewGroup parent){
QuestionView qv;
if (convertView == null) {
qv = new QuestionView (nContext, nQuestion[position], nDetail[position], nExpanded[position]);
} else {
qv = (QuestionView)convertView;
qv.setName(nQuestion[position]);
qv.setDetail(nDetail[position]);
qv.setExpanded(nExpanded[position]);
}
return qv;
}
But how do I call the method? If I have no old view and the parent isn't LayoutParams.FILL_PARENT
My onCreate:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Use our own list adapter
setListAdapter(new QuestionsListAdapter(this));
}
So how do I call the getView method, because if I run the code it isn't drawing. Somthing like this?
QuestionsListAdapter.getView( 0, convertView, parent);
You do not have to call the method. If you override the method in a customAdapter, it is called automatically each time the Adapter
gets data from your data source and puts it in a View
that represents an item in your ListView
.