W/RepoOperation﹕ Persisted write at /30987733 failed: FirebaseError: Invalid token in path
logcat的:
package org.jaberrio.personai2;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.TextView;
import java.util.Calendar;
public class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
DataBaseManager dataBaseManager = new DataBaseManager();
String date = String.valueOf(month) + "/" + String.valueOf(day) + "/" + String.valueOf(year);
dataBaseManager.tempSaveCurrentEvent(DataBaseManager.FieldTypes.DUE_DATE,date, getActivity().getApplicationContext());
TextView dueDate = (TextView)view.getRootView().findViewById(R.id.dueDate);
dueDate.setText(dataBaseManager.tempGetCurrentEvent(DataBaseManager.FieldTypes.DUE_DATE,getActivity().getApplicationContext()));
}
}
我正在调用dueDate.setText()但是它返回null。我调用了view.getRootView(),因为我在DatePicker的视图中,因此它应该返回包含我的dueDate TextView的视图。我也可以从调用DatePickerFragment的方法传递View,但我不知道如何。我猜测调用getRootView()时DatePicker视图不会返回包含R.id.dueDate的视图。提前谢谢。