public class showStatus extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showstatus);
addComments();
}
如果我从这里拨打 addComments(),那就太费劲了......
class sendCommentToWebsite extends
AsyncTask<String, String, String> {
String returnedComments;
String comment, userName, MarkerID;
@Override
public String doInBackground(String... params) {
}
@Override
public void onPostExecute(String returnedComments) {
super.onPostExecute(returnedComments);
JSONObject jsonObject;
try {
jsonObject = new JSONObject(returnedComments);
for (int i = 1; i <= jsonObject.length(); i++) {
JSONObject jsonInnerObject = jsonObject
.getJSONObject(Integer.toString(i));
String comment = jsonInnerObject.getString("comment_text");
String Comment_owner = jsonInnerObject
.getString("comment_owner");
addComments(comment,Comment_owner);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}//End of sendCommentToWebsite
*现在我想添加从网站
返回的所有评论*但是从这里addComments()无效
*另一个问题是我希望所有动态TextView都具有唯一ID
*如果这不是保存评论的好方法,还有其他保存评论的最佳方式吗?
因为如果他长时间点评评论,我希望用户编辑评论。
*谢谢你
public void addComments(String comment, String comment_owner) {
Toast.makeText(getBaseContext(), "working", Toast.LENGTH_LONG).show();
RelativeLayout statusLayout = (RelativeLayout) findViewById(R.id.showCommentLayout);
LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
TextView tv = new TextView(this);
tv.setTextColor(Color.GREEN);
tv.setLayoutParams(lparams);
tv.setText(comment);
this.statusLayout.addView(tv);
}//End of addComments
}//End of showStatus
答案 0 :(得分:0)
为了保存评论,为什么不使用Sqlite或SharedPreferences。