我从 Webservice 获取字符串值并尝试使用 Android 在 Edittext 中显示字符串值。我设法显示该值,但我得到双引号,例如:“12.12”。下面是我完成的代码。任何人都可以指导我的错误在哪里。提前致谢。
//Get the response
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream stream=httpEntity.getContent();
//Convert the stream to readable format
result= convertStreamToString(stream);
cText.setText(result);
public String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
}
catch (IOException e) {
e.printStackTrace();
}
finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}