I am trying to make a ListView with the first item displayed in a different layout , and the others in the general layout. Both layouts have the same elements, which in pairs have the same name. When I like it:
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
if(position == 0){
convertView = inflater.inflate(R.layout.article_list_top_item, parent, false);
Log.d("ALA", "pos = " + position + ", inflated top");
}
else {
convertView = inflater.inflate(R.layout.article_list_item, parent, false);
Log.d("ALA", "pos = " + position + ", inflated normal");
}
}
return convertView;
}
it did not work. From the magazine, which I could tell, inflater.inflatewas called 6 times, inflated top1 time and inflated normal5 times.
What is depicted, article [0] was in the layout article_list_top_item, and article [1] ~ [5] was in article_list_item.
Until this is normal, but the pattern repeats, which means that article [6], article [12], [18], ... were in the layout article_list_top_itemthat I did not want.
What can I do to ONLY the first article appeared in article_list_top_item ??
P.S. article_list_top_item.xml setText setImage .
else return convertView; //setText , .
, , , SwipeRefreshLayout
, .