你好,我是 webservices 和 json 的新手,所以我请求你帮助如何在 textView 中显示 JSONStringer 结果。
这是我正在处理的代码:
// Build JSON string
JSONStringer TestApp = new JSONStringer().object().key("id")
.value("1").key("name").value("manish").key("email")
.value("androidhub4you@gmail.com").key("country")
.value("india").endObject();
String entity = new StringEntity(TestApp.toString());
String var = entity.toString();
显示:
TextView tv = (TextView) findViewById (R.id.tvText);
tv.setText(var);
问题是它只是打印
org.apache.http.entity StringEntity....
。我非常感谢你的帮助。提前致谢。
最佳答案
改变
String var = entity.toString();
与
String var = EntityUtils.toString(entity)
StringEntity.toString()
返回对象的地址
关于java - 在 TextView 中显示 JSONStringer 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16997114/