For learning purposes I would like to write an Android application that will display a list of numbers from 0 to Integer.MAX_VALUE. I currently have an app that will display numbers from 0 to 100, this is easy because you can just create an array of numbers and then pass that to the Adapter, currently using ArrayAdapter. If I try that with an extremely large array the program crashes when it uses all available memory.
Looking at more advanced applications I noticed people with large data sets using databases and CursorAdapters. If that is the correct thing to do I can start reading on that. What I would like to do (although feel free to tell me this is wrong) is seed my ArrayAdapter with an array of length 100, or some relatively small length. From there as the user scrolls up or down I would like to modify the values in the array (or the Adapter) to increase as the user scrolls down, removing the smallest items in the list and appending larger values to the end of the list. If the user scrolls up, I would like to remove items from the end of the list and add new smaller values to the beginning.
As I stated for this project I have very little done so far.
package example.VariableListView;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class variablelistview extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
ArrayList<Integer> intItems = new ArrayList<Integer>();
for (int ii = 0; ii < 100; ii++) {
intItems.add(ii);
}
this.setListAdapter(new ArrayAdapter<Integer>(this,
android.R.layout.simple_list_item_1, intItems));
}
}
thanks in advance for any and all help.