• 1000
public void SearchEan(View view) {
List<Location> locationList = new ArrayList<>();
try {
JSONArray jsonArray = new JSONArray(product.getLocationHistoryData());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsLocationHistoryOBJ = jsonArray.getJSONObject(i);
Location location = new Location();
location.setLocation(jsLocationHistoryOBJ.getString("Location"));
location.setDate(jsLocationHistoryOBJ.getString("date"));
locationList.add(location);
}
product.setLocationHistory(locationList);
} catch (JSONException e) {
e.printStackTrace();
}
TableLayout tableLayout = findViewById(R.id.tableLayout);
for (int i = 0; i <product.locationHistory.size(); i++) {
TableRow row= new TableRow(**this**);
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
row.setLayoutParams(lp);
TextView tv = new TextView(**this**);
tv.setText(product.locationHistory.get(i).getLocation());
tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
row.addView(tv);
TextView tv2 = new TextView(**this**);
tv2.setText(product.locationHistory.get(i).getDate());
row.addView(tv2);
tableLayout.addView(row);
}}