I am trying to add values to array list for ploting xAxis value in mpandroid chart but while debugging array list returns Null
While adding in forloop it shows value but after the end of forloop array list is empty Help me
Code
private ArrayList<String> getXAxisValues() {
final ArrayList<String> xAxis = new ArrayList<>();
final Intent intent = getIntent();
final String getUserId = intent.getStringExtra("UserId");
new Thread(new Runnable() {
public void run() {
HttpRequest req = null;
try {
req = new HttpRequest("http://abc.sc.in/abc.php");
final String response = req.preparePost().withData("answerUserId="+getUserId).sendAndReadString();
JSONArray myObjects = null;
try {
myObjects = new JSONArray(response);
for (int ji = 1; ji < myObjects.length(); ji++) {
JSONObject jsonobject = myObjects.getJSONObject(ji);
final String Date = jsonobject.getString("date(answerDate)");
System.out.println("Date Response =====>: " + Date);
// The Values of Date (2 Dates [21,23]) here are shown while adding
xAxis.add(Date);
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
System.out.println("Here It shows [] after adding values ==============================>" + xAxis);
return xAxis;
}