รายละเอียดของการตอบ ::
ผมลองดูแล้ว แต่เหมือนค่าจาก หน้า Review มันไม่ส่งไปให้ viewreview อะครับ ไม่ทราบว่าผมผิดตรงไหนหรอ
Review
// ส่วนที่ดึงข้อมูล
try {
JSONArray data = new JSONArray(getJSONUrl(url));
final ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
for(int i = 0; i < data.length(); i++){
JSONObject c = data.getJSONObject(i);
map = new HashMap<String, String>();
map.put("id", c.getString("post_id"));
map.put("title", c.getString("post_title"));
//map.put("detail", c.getString("post_detail"));
//MyArrList.add(map);
String temp = c.getString("post_detail");
String detail;
if(temp.length() > 200) {
detail = temp.substring(0, 199);
} else {
detail = temp;
}
map.put("sdetail", detail);
MyArrList.add(map);
}
// สิ้นสุดการดึงข้อมูล
//ส่วนที่ให้กดแล้วไปหน้า viewreview
lisView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> myAdapter, View myView,
int position, long mylng) {
String sID = MyArrList.get(position).get("id")
.toString();
Intent newActivity = new Intent(ReviewActivity.this,ViewReview.class);
newActivity.putExtra("PostID", sID);
startActivity(newActivity);
}
});
ViewReview
Intent intent= getIntent();
final String sPostID = intent.getStringExtra("PostID");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("PostID", sPostID));
String resultServer = getHttpPost(url,params);
String strPostID = "";
String strTitle = "";
String strName = "";
String strDate = "";
String strDetail = "";
JSONObject c;
try {
c = new JSONObject(resultServer);
strTitle = c.getString("post_Title");
strName = c.getString("PostDate");
strDate = c.getString("Email");
strDetail = c.getString("PostDetail");
if(!strPostID.equals(""))
{
tTitle.setText(strTitle);
tName.setText(strName);
tDate.setText(strDate);
tDetail.setText(strDetail);
}
else
{
tTitle.setText("-");
tName.setText("-");
tDate.setText("-");
tDetail.setText("-");
}