0

I am doing an Android app with actionBar tabs. In one tab, there is a fragment with a custom ExtendedCalendarView.

I can get the current month in the calendar from the fragment every time I want.

What I want is to show the current month as the actionBar title, so I need to detect when the month changes. How I can do that? Thanks.

Mohammed Ali
  • 2,758
  • 5
  • 23
  • 41
Borja
  • 1,269
  • 1
  • 17
  • 30
  • Plz show some code. Are you using `ActionBar` or `ActionBarActivity`? – Mohammed Ali Dec 01 '14 at 08:13
  • I am using ActionBar. Which code do you need? The default code is that library, I only need something like a listener to detect the month change. – Borja Dec 01 '14 at 08:32
  • For setting action bar title: `ActionBar ab = getActionBar();` `ab.setTitle("Jan");` – Mohammed Ali Dec 01 '14 at 08:59
  • I know this, but It's not my question. I need to detect when the month has changed – Borja Dec 01 '14 at 09:30
  • I can provide some direction - look into the codes ExtendedCalendarView and see how it is implemented : https://github.com/tyczj/ExtendedCalendarView/blob/master/ExtendedCalendarView/src/com/tyczj/extendedcalendarview/ExtendedCalendarView.java ; it has onItemClick and onClick functions and the Class also implements some listeners... try using them or calling them. – Mohammed Ali Dec 01 '14 at 12:27
  • My problem is that I need something like the method "notifyDataSetChanged() of adapters, when you call that, it notifies to the adapter that it has to refresh the listView. In this case, I need something that when "refreshCalendar()" is called, notify the fragment to change the actionBar title. – Borja Dec 01 '14 at 12:55
  • How does the user change the month? I mean by clicking somewhere on the extended calendar view? On seeing the codes of ExtendedCalendarView i saw that it extends RelativeLayout. And `RelativeLayout` is a subclass of `View`. And `View` has an onClickListener : http://developer.android.com/reference/android/view/View.OnClickListener.html ; So what i am saying is try using the view's onClickListener and inside that listener check if `month value has changed from a previous one`. – Mohammed Ali Dec 01 '14 at 16:06
  • codes of extendedcalendarview: https://github.com/tyczj/ExtendedCalendarView/blob/master/ExtendedCalendarView/src/com/tyczj/extendedcalendarview/ExtendedCalendarView.java – Mohammed Ali Dec 01 '14 at 16:07
  • User changes by swyping, there is a gestureListener that calls the methods of "previous or next month". I think I have to use something like a callback to send the month from the view to the fragment, but I have no idea... – Borja Dec 01 '14 at 16:09
  • see this: http://stackoverflow.com/q/994840/3879470 Add a listener and call something like `ml.callback(this, "success");` from previousMonth() or nextMonth(). – Mohammed Ali Dec 01 '14 at 17:13

0 Answers0