I want my listview to repeat all rows after scrolling to the end, and so on. This is called infinite or circular, and you can find ways to implement it but none of these seems to work for my adapter. I tried this approach: How to create a closed (circular) ListView? but my app crashes when i put
@Override
public int getCount()
{
return Integer.MAX_VALUE;
}
Also, getItem doesent seem to "play along" with my adapter
@Override
public T getItem(int position)
{
return objects[position % objects.length];
}
Is there a way to implement something similar for my adapter? here's the code:
public class EntryAdapter extends ArrayAdapter<Item> {
private ArrayList<Item> items;
private Context fontcontext;
private LayoutInflater vi;
public EntryAdapter(Context context, ArrayList<Item> items) {
super(context,0, items);
fontcontext = context;
this.items = items;
vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
final Item i = items.get(position);
if (i != null) {
if(i.isSection()){
SectionItem si = (SectionItem)i;
v = vi.inflate(R.layout.list_item_section, null);
v.setOnClickListener(null);
v.setOnLongClickListener(null);
v.setLongClickable(false);
final TextView sectionView = (TextView) v.findViewById(R.id.list_item_section_text);
sectionView.setText(si.getTitle());
Typeface faceT = Typeface.createFromAsset(fontcontext.getAssets(),"fonts/Walkwayrounded.ttf");
sectionView.setTypeface(faceT);
final TextView conditionView = (TextView) v.findViewById(R.id.textViewn);
conditionView.setText(si.getCondition());
Typeface faceC = Typeface.createFromAsset(fontcontext.getAssets(),"fonts/Walkwayrounded.ttf");
conditionView.setTypeface(faceC);
}else{
EntryItem ei = (EntryItem)i;
v = vi.inflate(R.layout.list_item_entry, null);
final TextView title = (TextView)v.findViewById(R.id.list_item_entry_title);
final TextView subtitle = (TextView)v.findViewById(R.id.list_item_entry_summary);
if (title != null)
title.setText(ei.title);
if(subtitle != null)
subtitle.setText(ei.subtitle);
}
}
return v;
}
}
Any kind of approach to solve the problem will be appreciated!