When I try print the values to a textfield they come out as [Ljava.lang.String;@405af10
try {
JSONObject jObject = new JSONObject(byteArrayOutputStream.toString());
JSONArray Monday = jObject.getJSONArray("Monday");
String time = "";
String module = "";
String lecturer = "";
listAdapter = new ArrayAdapter<String[]>(this, R.layout.simplerow);
for (int i = 0; i < Monday.length(); i++)
{
time = Monday.getJSONObject(i).getString("time");
module = Monday.getJSONObject(i).getString("module");
lecturer = Monday.getJSONObject(i).getString("lecturer");
listAdapter.add(new String[] {time, module, lecturer});
}
mainListView.setAdapter(listAdapter);
} catch (Exception e) {
e.printStackTrace();
}
in the simplerow xml file I have
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
So each time a time, module or lecturer is printed it should be in it’s own textview box., but it’s not working and I don’t know why or how to fix it.
It is most likely because your
ArrayAdapteris set to accept in aStringarray (String []).Therefore you have a list of
Stringarrays, which is basically equivalent to a 2D array.This means, when the
ArrayAdapteris setting the Text to the TextView you specified, it is callingtoString()on the whole array object, hence the hashcode.Consider making your own
ArrayAdapterand override thegetView()method so that it does what you want to do. There are plenty of tutorials online, such as this one.