2016-11-12 2 views
1

Fragment에서 onCreateDialog() 메서드를 재정의 할 수 없습니다. 하지만 그것은 Activity에서 우선 적용하도록 허용하고 있습니다. 당신의 조각 .IN조각에서 onCreateDialog 메서드를 재정의하는 방법

@Override 
protected Dialog onCreateDialog(int id) { 
    if (id == 999) { 
     return new DatePickerDialog(this, myDateListener, year, month, day); 
    } 
    return null; 
} 

답변

5

사용 DialogFragment 은 날짜와 시간 선택기 대화 상자를 사용하려면 다른 방법이 있습니다 DialogFragment 클래스

public class Fragment extends DialogFragment { 

    @Override 
public Dialog onCreateDialog(Bundle savedInstanceState) { 

} 
} 
+1

에 쓸 수 있지만 이미 조각을 확장하는 문제가있는 경우 또는 발행

DatePickerDialog mDatepickerDialog = DatePickerDialog.newInstance(this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH) ); 

, 그것은 당신이 당신의 전체 코드를 – chandra

+0

을 확장 할 수 없습니다 경우 farment 당신은 사용할 수 있습니다 ... 그것은 일했다 !!!!! – sasikumar

관련 문제