Я пытаюсь передать ArrayList
функции, которая затем отобразит ее в формате списка, но, похоже, мои параметры неверны для Arrayadapter.
@Override
public void handleResult(final Result result) {
final RequestQueue mQueue = Volley.newRequestQueue(this);
String url = "https://fg3qzgb2va.execute-api.ap-southeast-1.amazonaws.com/sample";
JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, url, null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
for (int i = 0; i < response.length() ; i++) {
JSONObject jsonArray = response.getJSONObject(i);
String first = jsonArray.getString("Name");
String price = jsonArray.getString("Price");
int priceResult = Integer.parseInt(price);
String id = jsonArray.getString("id");
if(id.equals(result.getText())){
addItem.setName(first);
addItem.setPrice(priceResult);
MainActivity.resultTextView.setText("Name: " + addItem.getName() + "\n"+"Price: " + addItem.getPrice());
itemList = new ArrayList<>();
itemList.add(addItem.getName());
addItem.setName("");
addToList.addList(itemList);
}
//Storing into the list
}
} catch (JSONException e) {
e.printStackTrace();
}
public class AddToList extends AppCompatActivity {
ArrayAdapter<String> adapter;
public void addList(ArrayList<String> arrayList ){
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,arrayList);
adapter.notifyDataSetChanged();
MainActivity.list.setAdapter(adapter);
}
}