1

These are my JSON data:

[
    {"haberBaslik":"ekrem kimdir?"},
    {"haberBaslik":"doğa kimdir?"},
    {"haberBaslik":"biz kimiz?"},
    {"haberBaslik":"fatih naptı?"}
]

and this code only shows the latest data, but I need to show my all data

JSONArray jsonarray = new JSONArray(s);
for (int i = 0; i < jsonarray.length(); i++) {
    JSONObject jsonobject = jsonarray.getJSONObject(i);
    String Haberbaslik = jsonobject.getString("haberBaslik");
    tv1.setText(Haberbaslik);
}
Carnal
  • 21,744
  • 6
  • 60
  • 75

1 Answers1

2
JSONArray jsonarray = new JSONArray(s);
for (int i = 0; i < jsonarray.length(); i++) {
  JSONObject jsonobject = jsonarray.getJSONObject(i);
  String Haberbaslik = jsonobject.getString("haberBaslik");
  tv1.setText(tv1.getText()+ " "+Haberbaslik);
 }
Basi
  • 3,009
  • 23
  • 28