Java 在Android中回复现有的评论系统
因此,我们的应用程序中有一个评论系统,现在我们希望能够添加对特定评论的回复,比如Facebook墙 我们发布评论的Java方法:Java 在Android中回复现有的评论系统,java,php,android,mysql,Java,Php,Android,Mysql,因此,我们的应用程序中有一个评论系统,现在我们希望能够添加对特定评论的回复,比如Facebook墙 我们发布评论的Java方法: class PostComment extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog
class PostComment extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AddCommentActivity.this);
pDialog.setMessage("Posting Comment...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
// Check for success tag
int success;
String post_title = title.getText().toString();
String post_message = message.getText().toString();
//We need to change this:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(AddCommentActivity.this);
String post_username = sp.getString("username", "anon");
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", post_username));
params.add(new BasicNameValuePair("title", post_title));
params.add(new BasicNameValuePair("message", post_message));
Log.d("request!", "starting");
//Posting user data to script
JSONObject json = jsonParser.makeHttpRequest(
POST_COMMENT_URL, "POST", params);
// full json response
Log.d("Post Comment attempt", json.toString());
// json success element
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Log.d("Comment Added!", json.toString());
finish();
return json.getString(TAG_MESSAGE);
}else{
Log.d("Comment Failure!", json.getString(TAG_MESSAGE));
return json.getString(TAG_MESSAGE);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog once product deleted
pDialog.dismiss();
if (file_url != null){
Toast.makeText(AddCommentActivity.this, file_url, Toast.LENGTH_LONG).show();
}
}
}
}
我猜我们会制作一个arraylist
,从原始评论中选择commentid
,然后将其链接到回复,但我不知道怎么做。我通常不知道如何从这里开始
reply_id (INT AI)
reply_content (text)
reply_postid (INT)
reply_byusername (varchar)