1

I'm building an app in which I need a calendar so the user can pick a date. I'm trying to embed the Caldroid library in my project and I want to show the calendar not in a new Activity, but in a Dialog instead.

My questions are:

  1. Since I'm using an Activity which already has some widgets, do I need to change it to FragmentActivity?
  2. I want to show the Caldroid Dialog by pressing a calendar ImageButton, do I need a second FragmentActivity?
Andrew T.
  • 4,701
  • 8
  • 43
  • 62
Oh hi Mark
  • 153
  • 1
  • 8
  • 28

1 Answers1

0

Straight to your questions:

A) Caldroid from what I can see is just another fragment, therefore there is no need of changing your Activity to FragmentActivity check here (any ViewGroup can hold a fragment.

B) Let me see if I get this: You want on the click of an ImageButton that is located on your activity to show the Caldroid's calendar dialog? If that is the case then you don't need to do anything more than override the onClick() method of the ImageButton and implement it to launch Caldroid. No need to have a second fragment activity.

George Daramouskas
  • 3,720
  • 3
  • 22
  • 51
  • 1
    Thank you! I followed the steps, added the project and set the listener but there is a `FragmentTransaction t = getSupportFragmentManager().beginTransaction();` which causes an error. Also `R.id.calendar1` does not exist. Should I create it? – Oh hi Mark Feb 25 '15 at 22:05
  • Did you integrate the library with your application exactly as https://github.com/roomorama/Caldroid#setup instructs? Are you using Maven or Gradle? – George Daramouskas Feb 26 '15 at 07:32
  • I added `compile 'com.roomorama:caldroid:1.1.8'` to my gradle build file. – Oh hi Mark Feb 26 '15 at 13:17
  • What is the error you get from `FragmentTransaction t = getSupportFragmentManager().beginTransaction();`? post your stacktrace – George Daramouskas Feb 26 '15 at 13:19
  • 1
    I figured it out. It was simple but I new here. I opened the example and copy and paste the parts I needed. It's very straight forward. But instead of `t.replace` i used `t.attach` – Oh hi Mark Feb 26 '15 at 14:35