public class MainActivity extends Activity {
EditText userid;
EditText passwd;
Button login;
TextView text;
Handler handler = new Handler();
String result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userid = (EditText) findViewById(R.id.userid);
passwd = (EditText) findViewById(R.id.passwd);
login = (Button) findViewById(R.id.login);
text = (TextView) findViewById(R.id.text);
// 버튼 이벤트 처리
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDialog(1);
String userid1 = userid.getText().toString();
String passwd1 = passwd.getText().toString();
// 서버에 넘겨줄 파라미터 저장
ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(new BasicNameValuePair("userid", userid1));
list.add(new BasicNameValuePair("passwd", passwd1));
final String urlPath = "http://url주소/xml/xmlApp.php?userid="
+ userid + "&passwd=" + passwd;
// 네트워크 연동을 위한 작업 스레드 생성
Thread t = new Thread(new Runnable() {
@Override
public void run() {
InputStream is = requestGet(urlPath);
result = streamToString(is);
handler.post(new Runnable() {
@Override
public void run() {
text.setText(result);
removeDialog(1);
}
});
}
});
t.start();
}
});
} // end onCreate
// Get 요청처리 메소드
public InputStream requestGet(String requestUrl) {
try {
// 요청하기
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(requestUrl);
HttpResponse response = client.execute(request);
// 응답하기
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
return is;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}// end requestGet
//
public String streamToString(InputStream is) {
StringBuffer buffer = new StringBuffer();
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
String str = reader.readLine();
while (str != null) {
buffer.append(str);
str = reader.readLine();
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}// end streamToString
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
아이디와 비밀번호를 입력하면 위에 파란글씨로 표시되어있는 url로 접속하여
웹과 호출하고 아이디와 비밀번호 일치시 텍스트창에 아이디와 비밀번호를 띄워주는 것을 해보고 있는데요.
아이디 비번 입력후 버튼을 누르면 텍스트창에
android.widget.EditText@4178f7f8android.widget.EditText@417f3ba0 이라는 메시지가 나오는데요 어떻게 수정해야 할까요?