public void op() {
StringBuilder sb = new StringBuilder();
Intent intent = this.getIntent();
int code = intent.getIntExtra("code", 0);
String ch;
try {
URL url = new URL("http://localhost/op.php?num=" + code);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
status.setText(String.valueOf(conn.getResponseCode()) + "\n"
+ String.valueOf(HttpURLConnection.HTTP_OK));
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
while (true) {
String line = br.readLine();
if (line == null)
break;
sb.append(line + "\n");
}
br.close();
} else {
status.setText("http_not");
}
conn.disconnect();
}
} catch (Exception e) {
status.setText(e.toString());
}
String jsonString = sb.toString();
try {
int data = 0;
JSONArray ja = new JSONArray(jsonString);
for (int i = 0; i < ja.length(); i++) {
JSONObject jo = ja.getJSONObject(i);
// 결과물
data = jo.getInt("cb1_status");
}
// 결과 출력
if (data == 1) {
ch = "가동중";
status.setText(ch);
}
else if(data == 0) {
ch = "정지";
status.setText(ch);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
status.setText(e.toString());
}
}
지금 소스는 이렇게 되있습니다
op.php에서 디비값받아와서 텍스트뷰에 나오고있고요
버튼 2개를 추가해서 하나는 1의값을 DB에 전송해주고 하나는 0값을 전송해주려고합니다
여기서 어떻게 추가를 해줘야 할까여?