Android textview парсинг строк json
Столкнулся с проблемой. При выводе текста в TextView средствами парсинга json и записыванием через HashMap в TextView не создается новая строка, если текст в базе данных находится с новой строки
Как починить
public class ParseTask extends AsyncTask<Void, Void, String> {
HttpsURLConnection urlConnection = null;
BufferedReader reader = null;
String resultJson = "";
@Override
protected String doInBackground(Void... params){
try{
db = new DatabaseHelper(getContext());
String url_json = "https://**********/methods/******?access_token=" +
db.token();
URL url = new URL(url_json);
urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
StringBuffer buffer = new StringBuffer();
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null){
buffer.append(line);
}
resultJson = buffer.toString();
Log.d("FOR_LOG", resultJson);
} catch (Exception e){
e.printStackTrace();
}
return resultJson;
}
protected void onPostExecute(String strJson){
super.onPostExecute(strJson);
final ListView listView = (ListView)view.findViewById(R.id.agent_dialog);
String[] from = {"tv_author", "tv_textmsg", "tv_time"};
int[] to = {R.id.tv_author, R.id.tv_textmsg, R.id.tv_time};
ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> hashMap;
try{
JSONObject json = new JSONObject(strJson);
JSONArray jArray = json.getJSONArray("response");
for(int i = 0; i< jArray.length(); i++){
JSONObject jo = jArray.getJSONObject(i);
String id = jo.getString("id");
String author = jo.getString("author");
String message = jo.getString("message");
String date = jo.getString("date");
hashMap = new HashMap<String, String>();
if(db.nick().equals(jo.getString("author"))){
hashMap.put("tv_author", "Вы");
} else {
hashMap.put("tv_author", author);
}
hashMap.put("tv_textmsg", message);
hashMap.put("tv_time", date);
arrayList.add(hashMap);
}
final SimpleAdapter adapter = new SimpleAdapter(view.getContext(), arrayList, R.layout.list_agentchat, from, to);
listView.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
