空字符串...奇怪的情况

时间:2014-08-03 12:50:51

标签: android

我的代码部分:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

     if (requestCode == 2) {
         if (resultCode == RESULT_OK) {

             startnomos = data.getStringExtra("strnom1");
             startcity = data.getStringExtra("strct1");
1            Log.d("startnomos", startnomos);
2            Log.d("startcity", startcity);

        }
      }
    else if (requestCode == 3) {
        if (resultCode == RESULT_OK) {

             finalnomos = data.getStringExtra("fnlnom1");
             finalcity = data.getStringExtra("fnlcity1");
3             Log.d("finalnomos", finalnomos);
4             Log.d("finalcity", finalcity);

         }
     }
}


static final int DATE_DIALOG_ID = 0;
int yr, mon, day;
int hour, min;
 static final int TIME_DIALOG_ID = 1;

 @SuppressWarnings("deprecation")
 public void showDatePickerDialog(View v) {
    Calendar today = Calendar.getInstance();
     yr = today.get(Calendar.YEAR);
    mon = today.get(Calendar.MONTH);
    day = today.get(Calendar.DAY_OF_MONTH);
     hour = today.get(Calendar.HOUR);
    min = today.get(Calendar.MINUTE);
     showDialog(TIME_DIALOG_ID);
     showDialog(DATE_DIALOG_ID);
 }

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, dateSetListener, yr, mon, day);
    case TIME_DIALOG_ID:
        return new TimePickerDialog(this, timeSetListener, hour, min, true);
    }
     return null;
}

 private DatePickerDialog.OnDateSetListener dateSetListener = new  DatePickerDialog.OnDateSetListener() {

     @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear,
             int dayOfMonth) {
         // TODO Auto-generated method stub
        yr = year;
         mon = monthOfYear + 1;
         day = dayOfMonth;
         depDate1 = (EditText) findViewById(R.id.depDate1);
         depDate1.setText(day + " - " + mon + " - " + yr);
    }

};

 private TimePickerDialog.OnTimeSetListener timeSetListener = new  TimePickerDialog.OnTimeSetListener() {

    @Override
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
         // TODO Auto-generated method stub
         hour = hourOfDay;
        min = minute;
        depTime1 = (EditText) findViewById(R.id.depTime1);
         depTime1.setText(hour + " : " + min);

    }

};





 public void onClick(View btnregidiot) {
    // TODO Auto-generated method stub

    new RegisterIdiot().execute();

}


class RegisterIdiot extends AsyncTask<String, String, String> {

    /**
     * Before starting background thread Show Progress Dialog
     * */
    boolean failure = false;

    @Override
     protected void onPreExecute() {
        super.onPreExecute();
         eidmet1 = eidosmetaf1.getSelectedItem().toString();
        w1 = weight.getText().toString();

         dpDt1 = depDate1.getText().toString();
         dpTm1 = depTime1.getText().toString();
        exdyp1 = exeidypeir1.getSelectedItem().toString();
        comments = comments2.getText().toString();


        Log.d("eidmet1", eidmet1);
        Log.d("w1", w1);
    5   Log.d("fnlnom1", ""+finalnomos);
    6   Log.d("fnlcity1", ""+finalcity);
        Log.d("dpDt1", dpDt1);
        Log.d("dpTm1", dpTm1);
        Log.d("exdyp1", exdyp1);
        Log.d("comments", comments);
    7   Log.d("strnom1", "" +startnomos);
    8   Log.d("strct1", "" +startcity);

非常奇怪的情况是第1,2,3,4行中的Log.d给出了正确的答案,第5,6行也是正确的但是第7,8行给出了空!是不是很奇怪?与finalnomos,finalcity相比,startnomos,startcity是类似的情况。 提前谢谢

0 个答案:

没有答案