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,284
  • 6
  • 56
  • 73

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
  • 2,892
  • 22
  • 28