我正在尝试使用自定义 datePicker日期选择器
但是在片段内膨胀根布局时出现此错误:
public void button_click(View view) {
// Create the dialog
final Dialog mDateTimeDialog = new Dialog(view.getContext());
// Inflate the root layout
final RelativeLayout mDateTimeDialogView = (RelativeLayout)getLayoutInflater()
.inflate(R.layout.datepick,false);
.....
我怎样才能解决这个问题 ?
编辑
此代码有效:
// Inflate the root layout
LayoutInflater inflater = (LayoutInflater) view.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater.inflate(R.layout.datepick, null);