嗨在我的應用程序中我創建了一個form.in,第一個intial是在android中的微調這些初始字段值來自數據庫,我想顯示該值到初始微調,但值是不顯示到dataset中。爲此,我創建了一個名爲getpatient.php的php文件,只有我獲得了spinner值。 任何人都可以幫助我。
聯繫我們數據庫值不顯示在Android微調框
public class ContactUs extends Activity implements OnClickListener
{
EditText regno1,fname1,mname1,lname1,dob1,age1,f_hname1,adress1,tel_o1,pin_zip1,tel_r,email1,mobile1,id_prof1,b_group1,name_kin1,realition1;
String data="";
TextView tv1;
Button back,home,choosefile;
Spinner intial,pmaincat,pcatory,religion,caste;
RadioGroup sex,payment;
RadioButton rb;
String initial_id;
private EditText fromDateEtxt;
private DatePickerDialog fromDatePickerDialog;
private SimpleDateFormat dateFormatter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.contactus);
tv1=(TextView) findViewById(R.id.tv);
payment = (RadioGroup) findViewById(R.id.sex);
int selectedId = payment.getCheckedRadioButtonId();
rb = (RadioButton) findViewById(selectedId);
back=(Button) findViewById(R.id.back);
home=(Button) findViewById(R.id.home);
fname1=(EditText) findViewById(R.id.fname);
lname1=(EditText) findViewById(R.id.lname);
regno1=(EditText) findViewById(R.id.rgno);
mname1=(EditText) findViewById(R.id.mname);
age1=(EditText) findViewById(R.id.age);
f_hname1=(EditText) findViewById(R.id.f_hname);
adress1=(EditText) findViewById(R.id.adress);
tel_o1=(EditText) findViewById(R.id.telo);
pin_zip1=(EditText) findViewById(R.id.pzipcode);
tel_r=(EditText) findViewById(R.id.tel_r);
email1=(EditText) findViewById(R.id.email);
mobile1=(EditText) findViewById(R.id.mobile);
id_prof1=(EditText) findViewById(R.id.idprof);
b_group1=(EditText) findViewById(R.id.bgroup);
name_kin1=(EditText) findViewById(R.id.name_kin);
realition1=(EditText) findViewById(R.id.relationship);
intial=(Spinner)findViewById(R.id.intial);
pmaincat=(Spinner)findViewById(R.id.pmaincat);
pcatory=(Spinner)findViewById(R.id.pcatgory);
religion=(Spinner)findViewById(R.id.religion);
caste=(Spinner)findViewById(R.id.caste);
sex=(RadioGroup)findViewById(R.id.sex);
payment=(RadioGroup)findViewById(R.id.paymentmode);
tv1.setText("PATIENT REGISTRATION");
final Button photo1 = (Button) findViewById(R.id.photo);
Button Send = (Button) findViewById(R.id.Send);
Send.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
String first_name = fname1.getText().toString();
String middle_name = mname1.getText().toString();
String last_name = lname1.getText().toString();
String reg_no = regno1.getText().toString();
String dob = fromDateEtxt.getText().toString();
String age = age1.getText().toString();
String address = adress1.getText().toString();
String phone_office = tel_o1.getText().toString();
String fh = f_hname1.getText().toString();
String pin = pin_zip1.getText().toString();
String phone_resi = tel_r.getText().toString();
String email = email1.getText().toString();
String mobile_no = mobile1.getText().toString();
String id_proof = id_prof1.getText().toString();
String b_group = b_group1.getText().toString();
String name_of_kin = name_kin1.getText().toString();
String relation = realition1.getText().toString();
String pmode = rb.getText().toString().trim();
String photo = photo1.getText().toString();
String pmc=pmaincat.getSelectedItem().toString();
String pc=pcatory.getSelectedItem().toString();
String religion_id=religion.getSelectedItem().toString();
String caste_id=caste.getSelectedItem().toString();
dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.US);
findViewsById();
setDateTimeField();
if(first_name.equals(""))
{
fname1.setError("Please Enter First Name");
}
else if(last_name.equals(""))
{
lname1.setError("Please Enter Last Name");
}
if(reg_no.equals(""))
{
fname1.setError("Please Select Religon");
}
else if(last_name.equals(""))
{
lname1.setError("Please Enter Last Name");
}
/*else if(mobile.equals(""))
{
mobile1.setError("Please Enter Mobile No.");
}
else if(!isValidMobile(mobile)){
}
else if(email.equals(""))
{
email1.setError("Please Enter EmailId");
}
else if(!isValidMail(email)){
}*/
else
{
try{
String queryString ="reg_no="+ reg_no
+"&pmc="+pmc+"&pc="+pc+ "&initial_id="+initial_id+"&first_name="+first_name+"&middle_name="+middle_name+"&last_name="+last_name
+"&fh="+fh+"&religion_id="+religion_id+"&dob="+dob+"&caste_id="+caste_id+"&address="+address+"&pin="+pin
+"&email="+email+"&id_proof="+id_proof+"&phone_office="+phone_office+"&phone_resi="+phone_resi+"&mobile_no="+mobile_no+"&name_of_kin="+name_of_kin
+"&relation="+relation+"&photo="+photo+"&pmode="+pmode;
data = DatabaseUtility.executeQueryPhp("pat_registration",queryString);
/*fname1.setText("");
lname1.setText("");
mobile1.setText("");
altmob1.setText("");
email1.setText("");
comment1.setText("");*/
Toast.makeText(
ContactUs.this,
"Message:Records Saved Sucessfully",
Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
});
String result = DatabaseUtility.executeQueryPhp("getpatient","");
try
{
JSONArray JA=new JSONArray(result);
JSONObject json= null;
final String[] intial = new String[JA.length()];
for(int i=0;i<JA.length();i++)
{
json=JA.getJSONObject(i);
intial[i] = json.getString("initial_name");
}
final Spinner sp = (Spinner) findViewById(R.id.intial);
List<String> list = new ArrayList<String>();
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(getApplicationContext(), android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(dataAdapter);
sp.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long id)
{
// TODO Auto-generated method stub
String initial_id=sp.getSelectedItem().toString();
Toast.makeText(getApplicationContext(), initial_id,
Toast.LENGTH_LONG).show();
Log.e("Item",initial_id);
}
public void onNothingSelected(AdapterView<?> arg0)
{
// TODO Auto-generated method stub
}
});
}
catch(Exception e)
{
Log.e("Fail 3", e.toString());
}
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
onBackPressed();
}
});
home.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent in=new Intent(getApplicationContext(),MainActivity.class);
startActivity(in);
}
});
}
private void findViewsById() {
fromDateEtxt = (EditText) findViewById(R.id.dob);
fromDateEtxt.setInputType(InputType.TYPE_NULL);
fromDateEtxt.requestFocus();
}
private void setDateTimeField() {
fromDateEtxt.setOnClickListener(this);
Calendar newCalendar = Calendar.getInstance();
fromDatePickerDialog = new DatePickerDialog(this,
new OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
fromDateEtxt.setText(dateFormatter.format(newDate
.getTime()));
}
}, newCalendar.get(Calendar.YEAR),
newCalendar.get(Calendar.MONTH),
newCalendar.get(Calendar.DAY_OF_MONTH));
}
@Override
public void onBackPressed(){
super.onBackPressed();
}
private boolean isValidMail(String email)
{
boolean check;
Pattern p;
Matcher m;
String EMAIL_STRING = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
p = Pattern.compile(EMAIL_STRING);
m = p.matcher(email);
check = m.matches();
if(!check)
{
email1.setError("Not Valid Email");
}
return check;
}
private boolean isValidMobile(String mobile)
{
boolean check;
if(mobile.length() < 6 || mobile.length() > 13)
{
check = false;
mobile1.setError("Not Valid Number");
}
else
{
check = true;
}
return check;
}
public void onNothingSelected(AdapterView<?> arg0) {
}
public void onClick(View view) {
if (view == fromDateEtxt) {
fromDatePickerDialog.show();
}
}
您是否在LogCat中遇到任何錯誤? – 2014-10-30 12:17:25