У меня есть класс модели, который заполняется в Fragment
.Есть ли способ получить доступ к списку данных, хранящихся в классе model
в моем second activity
?
вот мой класс модели:
public class Idea {
private String id, name, voted;
public Idea(String id, String name, String voted) {
this.id = id;
this.name = name;
this.voted = voted;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getVoted() {
return voted;
}
public void setVoted(String voted) {
this.voted = voted;
}
}
РЕДАКТИРОВАТЬ: вот фрагмент в моем fragment
, где заполняется класс model
:
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONArray products = new JSONArray(response);
for (int i = 0; i<products.length(); i++) {
JSONObject productObject = products.getJSONObject(i);
String id = productObject.getString("id");
String name = productObject.getString("name");
String voted = productObject.getString("voted");
Idea idea = new Idea(id, name, voted);
ideaList.add(idea);
}
ideaListAdapter = new IdeaListAdapter(getActivity().getApplicationContext(), ideaList);
recyclerViewIdeaFragment.setAdapter(ideaListAdapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
Я думаю, правильный вопрос - как я могу получить значения внутри model
класса