I have added a calendar view in a dialog box. The dialog box appears on a button click. The problem I faced is that, when the dialog box appears, the calendar view does not display current month and year on top. But when I changed the month, the month and year on top appears (for current month also). I want to show this month and year on initial dialog show. Please help me on this. Thanks in advance.
I haven't enough reputation to post a screen shot. Sorry for this.
This is the code :
date.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout ll= (RelativeLayout)inflater.inflate(R.layout.calendar_dialog, null, false);
final CalendarView cv = (CalendarView) ll.getChildAt(0);
cv.setOnDateChangeListener(new OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
// TODO Auto-generated method stub
String date = dayOfMonth+"/"+(month+1)+"/"+year;
filterNews(date);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(FirstView.this, AlertDialog.THEME_HOLO_DARK);
builder.setTitle("News Calendar")
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing.
}
}
);
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
});
date is a Button.