2017-02-14 85 views
0

像對話框的標題白的觀點如何刪除DialogFragment未來的DatePickerDialog顯示DialogFragment

enter image description here

這裏是白的觀點標題Android的日期選擇參考我DialogFragment代碼:

public class DatePickerFrgDialog 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); 
     DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day); 

     // Create a new instance of DatePickerFrgDialog and return it 
     return dialog; 
    } 

    @Override 
    public void onDateSet(DatePicker view, int year, int month, int day) { 


    } 

如果任何人遇到此問題,請分享解決方案。

+0

嘗試此'mProjectsDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);' –

+0

都能跟得上。沒有工作 –

回答

2

嘗試此代碼:

 @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
     Dialog dialog = super.onCreateDialog(savedInstanceState); 

     // request a dialog without the title 
     dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
     DatePickerDialog date_picker_dialog = new DatePickerDialog(getActivity(), this, year, month, day); 
     date_picker_dialog.setTitle(""); 
     return dialog; 
    } 

使用:

date_picker_dialog.setTitle(""); 

或:

date_picker_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
+0

如果我使用這個'date_picker_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);'標題回來。如果我使用這個'date_picker_dialog.setTitle(「」)'那麼它的工作原理 –

+0

好的... thnkx建議 – rafsanahmad007