I did not understand the Error i am getting;
my elements declared as following;
ListView listViewLocations;
private ArrayAdapter<String> listAdapter ;
ArrayList<Long> addressList = new ArrayList<Long>();
and inside onCreate;
listViewLocations = (ListView) findViewById(R.id.listViewLocations);
ArrayList<Long> addresses = new ArrayList<>();
then the method displayed in the picture.
In my Stacktrace i made sure to log the final ArrayList by commenting the code and adding the log.i statement in order to confirm the retrieval of Data, and it is logging it as an Array;
5-08 14:28:06.265 22794-22794/net.we4x4 I/myTag: [20.4203339/84.5712178, 62.4334592/94.5716614, 22.4214592/59.5711114]
Simply i am trying to put this Array in a listView and i followed a simple tutorial on how to do so :
http://windrealm.org/tutorials/android/android-listview.php
Then i tried declaring the ArrayList in a different way;
ListView listViewLocations;
private ArrayAdapter<String> listAdapter ;
ArrayList addressList;
to resolve the redline (error shown in the picture)
and i got this error in my stack trace;
05-08 15:12:16.790 22349-22349/net.we4x4 E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.we4x4, PID: 22349
java.lang.NullPointerException
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)
at android.widget.ListView.setAdapter(ListView.java:486)
at net.we4x4.GPSlocations.listAddresses(GPSlocations.java:228)
at net.we4x4.GPSlocations.access$000(GPSlocations.java:47)
at net.we4x4.GPSlocations$1.onClick(GPSlocations.java:93)
at android.view.View.performClick(View.java:4508)
at android.view.View$PerformClick.run(View.java:18675)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)