コード例 #1
0
  private Dialog locationPicker() {
    AlertDialog.Builder locationPickerBuilder = new AlertDialog.Builder(this);
    locationPickerBuilder.setTitle("Set task location");

    View content =
        getLayoutInflater()
            .inflate(R.layout.editlocation, (ViewGroup) findViewById(R.id.editLocation));
    locationPickerBuilder.setView(content);

    EditText longitudeText = (EditText) content.findViewById(R.id.longitudeText);
    EditText latitudeText = (EditText) content.findViewById(R.id.latitudeText);

    latitudeText.setText(String.valueOf(location().latitude()));
    longitudeText.setText(String.valueOf(location().longitude()));

    locationPickerBuilder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            Dialog locationPicker = (Dialog) dialogInterface;
            EditText longitudeText = (EditText) locationPicker.findViewById(R.id.longitudeText);
            EditText latitudeText = (EditText) locationPicker.findViewById(R.id.latitudeText);
            double longitude = Double.valueOf(longitudeText.getText().toString());
            double latitude = Double.valueOf(latitudeText.getText().toString());
            task.add(TaskAdapter.LOCATION, new CMGeoPoint(longitude, latitude));
            setLocation();
          }
        });

    return locationPickerBuilder.create();
  }
コード例 #2
0
 private void setTaskName() {
   EditText taskName = getTaskNameComponent();
   taskName.setText(task.getString(TaskAdapter.TASK_NAME, ""));
 }