我已通过DatePicker
中的ImageView
实施了Fragment
。
@NonNull
@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);
}
// Called when the user presses "OK" on the DatePicker
@Override
public void onDateSet(android.widget.DatePicker datePicker, int i, int i1, int i2) {
// Do something with the date chosen by the user
String date = datePicker.getDayOfMonth() + "-" + datePicker.getMonth() + "-" + datePicker.getYear();
}
我希望在我的调用Fragment
中找到一个日期选择,调用DatePicker
就像这样:
public class APD extends Fragment {
[...]
public void showDatePickerDialog() {
DatePicker datePicker = new DatePicker();
datePicker.show(getActivity().getSupportFragmentManager(), "datePicker");
}
calendar_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDatePickerDialog();
}
});
[...]
}
如何实现?
答案 0 :(得分:1)
您可以直接在片段上捕捉日期...请参阅此代码
Traceback (most recent call last):
File "/usr/local/bin/conda", line 7, in <module>
from conda.cli.main import main
File "/usr/local/lib/python2.7/dist-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/usr/local/lib/python2.7/dist-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/usr/local/lib/python2.7/dist-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/usr/local/lib/python2.7/dist-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named ruamel.yaml.comments