Android show marker onClick button

I want to plot all the coordinates of latitude and longitude values I get. Check the first and last of the plot and change with different icons. Add Poly lines on each mark plot and buttons on popup that can hide/dismiss.

The problem I am having now is that whenever I remove the for-loop outside the button I am having a null pointer error.