if(list_itemArrayList == null);
list_itemArrayList = new ArrayList<list_item>();
try {
if (getIntent().hasExtra("json")) {
JSONObject json = new JSONObject(getIntent().getStringExtra("json"));
title = json.getString("postTitle");
name = json.getString("postName");
Log.i("asd","잘된다1");
if(list_itemArrayList == null);
// list_itemArrayList.add(new list_item("제목: "+title,"작성자: "+name,""));
}
Log.i("asd","잘된다2:");
if(list_itemArrayList == null);
Log.i("asd","잘된다3:");
list_itemArrayList.add(new list_item("제목: "+title,"작성자: "+name,""));
} catch (JSONException e) {
e.printStackTrace();
}
ListAdapter = new listAdapter(MainActivity.this,list_itemArrayList);
list1.setAdapter(ListAdapter);
list1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
try {
if (getIntent().hasExtra("json")) {
JSONObject json = new JSONObject(getIntent().getStringExtra("json"));
title = json.getString("postTitle");
name = json.getString("postName");
Intent intent = new Intent(getApplicationContext(), readboard.class);
intent.putExtra("json", json.toString());
startActivity(intent);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
검색해보니 맨위에 줄처럼 if(list_itemArrayList == null); << 이렇게 설정하면 정상작동 된다고 검색한내용에 나와있었으나 제 코딩에서는 맞지않는지 리스트뷰에 데이터가 덮어씌워집니다. 중간에
if(list_itemArrayList == null);
// list_itemArrayList.add(new list_item("제목: "+title,"작성자: "+name,""));
}
Log.i("asd","잘된다2:");
if(list_itemArrayList == null);
Log.i("asd","잘된다3:");
list_itemArrayList.add(new list_item("제목: "+title,"작성자: "+name,""));
} catch (JSONException e) {
e.printStackTrace();
}
여기서 받는부분이 잘못된건가요?