에서 텍스트를 편집에서 데이터를 가져 오는 세 글고안드로이드 : 나는 데 서버
- 이름
- 이름
- 이메일
나는이 글고 치기가 자동으로 한 번으로 로그인 채워하려면 사용자와 나는 json
을 사용하여 서버에서이 값을 원합니다. 누구든지이 일을 도울 수 있습니까? 나는 json 파싱에 초보자입니다. 도와주세요.
에서 텍스트를 편집에서 데이터를 가져 오는 세 글고안드로이드 : 나는 데 서버
나는이 글고 치기가 자동으로 한 번으로 로그인 채워하려면 사용자와 나는 json
을 사용하여 서버에서이 값을 원합니다. 누구든지이 일을 도울 수 있습니까? 나는 json 파싱에 초보자입니다. 도와주세요.
EditText의 값을 얻기 위해 click에서 메소드를 구현해야합니다.
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에 그 값을 넣어야 할 필요가 있을까? 아니면 내가 할 수 있을까? ...... like this : username.setText (사용자 이름); 대답을 편집하십시오 제발 – Zamani
안녕하세요,'return jobject' line..it에서 JSONObject로 반환 유형을 변경하라는 오류가 나타납니다. –
오 죄송합니다! 내 대답을 다시 읽어라! –
무엇을 시도 했습니까? –
안녕하세요! 여기에 약간의 코드 저널이 있어야합니다. 그래서 아이디어를 얻을 수 있습니까? – Hasmukh
지금까지 무엇을 했습니까? 다룬 게시물이나 자습서는 무엇입니까? – Egor