String[] names = new String[MainActivity.test.size()];
for(int i = begin; i<count; i++)
{
names[i] = MainActivity.test.get(i).getName();
}
...
d.setName(names[i]);
...
bar.setBars(points);
Have you checked the length of your names array versus count? It's likely that you are generating an array that is larger than the size of count, and because of that you're passing null later to d.setName, which ends up causing an exception later when calling bar.setBars.