获得在编辑文本数据,我有三个EditText上安卓:从服务器
- 用户名
- 名
- 电子邮件
我要填补这些EditText上自动登录后通过用户和我想要从服务器使用这些值使用json
。 任何人都可以帮助我做到这一点。我是一个json解析的新手,所以请帮助
获得在编辑文本数据,我有三个EditText上安卓:从服务器
我要填补这些EditText上自动登录后通过用户和我想要从服务器使用这些值使用json
。 任何人都可以帮助我做到这一点。我是一个json解析的新手,所以请帮助
你必须实现方法点击获取EditText的值。
String username = youedittext.getText().toString();
String name = youedittext2.getText().toString();
String email = youedittext3.getText().toString();
DefaultHttpClient client = new DefaultHttpClient();
ArrayList<NameValuepair> nvp = new ArrayList<NameValuePair>();
nvp.add(new BasicNameValuePair("username", username));
nvp.add(new BasicNameValuePair("name", name));
nvp.add(new BasicNameValuePair("mail", mail));
HttpPost hpost = new HttpPost(url);
hpost.setEntity(new UrlEncodedFormEntity());
HttpResponse response = client.execute(hpost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
String result = sb.toString();
JSONObject jobject = new JSONObject(result);
//Here you have to read the JSONObject it's very easy
Log.i("Content:",jobject.toString());
我认为这个用户需要将数据填充到edittext中,所以你的代码不够完整,你需要把这些值放到edittext中,或者我可以为你做吗?......像这样:username.setText(用户名);请编辑您的答案 – Zamani 2012-07-09 11:30:52
嘿,我收到'返回jobject'线错误。它说要将返回类型更改为JSONObject。 – 2012-07-09 11:39:22
对不起!再读一遍我的答案! – 2012-07-09 11:41:24
你试过了什么? – 2012-07-09 11:11:07
嘿!你需要在这里通过一些代码snipest ..所以我们可以得到想法? – Hasmukh 2012-07-09 11:11:30
到目前为止你做了什么?您已涵盖的任何帖子或教程? – Egor 2012-07-09 11:11:45