Please try below code it may solve your issue :
Java File :
public class MainActivity extends AppCompatActivity {
TextView txtname,txtcount,txtspam,txtresults;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtname = (TextView)findViewById(R.id.txtname);
txtcount = (TextView)findViewById(R.id.txtcount);
txtspam = (TextView)findViewById(R.id.txtspam);
txtresults = (TextView)findViewById(R.id.txtresults);
String response = "{\"results\":[{\"displayName\":\"Jack\",\"count\":\"5\",\"results\":[\"jack\",\"sam\",\"kelly\"],\"spam\":\"14\"}]}";
String name="",count="",spam="",results="";
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("results");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = jsonArray.getJSONObject(i);
name = jo.getString("displayName");
count = jo.getString("count");
spam = jo.getString("spam");
JSONArray jsonArray1 = jo.getJSONArray("results");
for(int j=0;j<jsonArray1.length();j++){
results += jsonArray1.get(j)+",";
}
}
txtname.setText(name);
txtcount.setText(count);
txtspam.setText(spam);
txtresults.setText(results);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
XML File :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" >
<TextView
android:id="@+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtresults"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtspam"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>