0

I am using showDialog() to show a DatePickerDialog. I want to change or remove the dialog's title.

I tried adding these code

dlg = new DatePickerDialog(this, dsl, mYear, mMonth, mDay);
dlg.init(mYear, mMonth, mDay, new onDateChanedListener() {
    @Override
    public void onChanged(WheelView wheel, int oldValue,
            int newValue) {
        // TODO Auto-generated method stub
    }
});

But the Eclipse shown

The method init(int, int, int, new onDateChanedListener(){}) is undefined

Then I tried to

extends Activity implements OnClickListener, OnDateChangedListener

I set to log the date

@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
        int dayOfMonth) {
    Log.i("info", year + "/" + monthOfYear + "/" + dayOfMonth);
}

But I didn't get the log info. Does anyone know how to use showDialog() to change or set the title?

flx
  • 14,146
  • 11
  • 55
  • 70
dickfala
  • 3,246
  • 3
  • 31
  • 52

2 Answers2

0

the method ShowDialog() was deprecated in API 13 so don't use it. u can simply use it as below

DatePickerDialog dp = new DatePickerDialog(
MainActivity.this, new DatePickerDialog.OnDateSetListener() {

    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
        Toast.makeText(MainActivity.this,
        dayOfMonth+"-"+(++monthOfYear)+"-"+year,
        Toast.LENGTH_LONG).show();

    }
},2014, 1, 24); 

dp.setTitle("My title");
dp.show();
kevz
  • 2,727
  • 14
  • 39
  • sorry,@kevz. I have write hide year field in protected Dialog onCreateDialog(int id) {}. If you set dp.setTitle. When the dialog turn on , user in onChanged date. The title will show date, not hide year. So I need find how to write set title in unchanged about use ShowDialog(). Thanks. – dickfala Feb 24 '14 at 05:51
  • didn't got wt u want exactly? plz write in steps wt u seek to achieve? – kevz Feb 24 '14 at 06:58
  • I haven't find nice solution. So I changed method to hide the dialog title. If you have better solution, we can discuss – dickfala Feb 24 '14 at 08:27
0

I find other changed method. I removed the title when the date picker turn on. we just set " (dialog object).setTitle(null); We can hide the title.

dickfala
  • 3,246
  • 3
  • 31
  • 52