0
基本上我試圖將用戶輸入的值傳遞給一個url並顯示基於該結果的結果....作爲即時通訊沒有錯誤我不太確定什麼錯誤。任何幫助是極大的讚賞將用戶輸入的值傳遞給url並顯示結果
當我上的按鈕沒有任何反應單擊......我有事件偵聽增加等
package com.example.jsonrestclient;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.EditText;
public class MainActivity extends Activity {
protected TextView tv1;
protected TextView tv2;
protected TextView tv3;
protected TextView tv4;
protected EditText ET1;
protected String ET2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.textView1);
tv2 = (TextView) findViewById(R.id.textView2);
tv3 = (TextView) findViewById(R.id.textView3);
tv4 = (TextView) findViewById(R.id.textView4);
ET1 = (EditText) findViewById(R.id.editText1);
ET2 = ET1.getText().toString();
}
public void button1OnClick(View v) {
String patientString = HttpHandler.HttpGetExec(HttpHandler.baseURI + ET2);
String patientFName = "NOT FOUND",
patientLName = "NOT FOUND",
DOB = "NOT FOUND",
patientGender = "NOT FOUND",
hospitalNumber = "NOT FOUND";
JSONObject patientObj = null;
try {
patientObj = new JSONObject(patientString);
patientFName = (String) patientObj.get("PatientFName");
patientLName = (String) patientObj.get("PatientLName");
DOB = (String) patientObj.get("DOB");
patientGender = (String) patientObj.get("PatientGender");
hospitalNumber = (String) patientObj.get("HospitalNumber");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tv1.setText(patientFName + " " + patientLName);
tv2.setText("DOB" + " " + DOB);
tv3.setText("Gender" + " " + patientGender);
tv4.setText("Hospital" + " " + hospitalNumber);
}
}
是你在xml中定義的按鈕的onClick?如果是,則顯示代碼 – 2013-03-13 14:03:55
ET2在ET1中寫入任何內容之前進行評估 – njzk2 2013-03-13 14:19:49