I just started android course and I am like native to it. I want to understand the below lines of code used in custom Array adapters.
public View getView(int position, View convertView, ViewGroup parent) {
// Check if the existing view is being reused, otherwise inflate the view
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item, parent, false);
}
Can you please explain the below details.
What is the parameter definitions of View convertView, ViewGroup parent and can you please explain each parameter for better understanding.
I understood what is LayoutInflater: it is used to inflate the layout for the view in the given context. But I didn't understand the Inflate method and it parameters. Can you please explain inflate(R.layout.list_item, parent, false) method and each of it parameters.
I understood Position parameter in the getview declaration as below. Please correct me if I am wrong
Position is used to get the data from the arrayadapter for a particular position of the listview in the device. More over the data that will be populated is the data at the current index of the arrayadapter.
Please Note: I had searched android developers website, and blogs to understand the getview method. But no luck. Please assist.
Regards, Nithin.