3

And in main activity I have this

public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new uSharedUtility.TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}

But I am getting this error:

Error:(566, 26) error: cannot find symbol method getSupportFragmentManager()

After searching I find out that I can make this go away by extending from FragmentActivity

But currently my MainActivity is extending from public class Main extends ListActivity due to some earlier requirements.

Is there any other way I can solve this issue excepting for changing extending classes.?

Community
  • 1
  • 1
Maven
  • 14,587
  • 42
  • 113
  • 174

2 Answers2

7

getSupportFragmentManager() is method of FragmentActivity. Your Parent activity should have extends FragmentActivity

Check this

http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

Ganesh AB
  • 4,652
  • 2
  • 18
  • 29
0

There are other reasons for the same error message. You might need to instead call getFragmentManager()

As noted in the accepted answer to this related thread: Difference between Fragment And FragmentActivity

Brian Davis
  • 345
  • 4
  • 9