I\'m getting the following error: \"The method getSupportFragmentManager() is undefined for the type new View.OnClickListener(){}\" in my fragment
Try changing your code to this:
public class ObstetricsFragment1 extends SherlockFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
//Fragment Layout
View view = inflater.inflate(R.layout.obstetricsfragment1, container, false);
Button mPickLMPDate = (Button) view.findViewById(R.id.pickLMPDate);
mPickLMPDate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LMPDatePickerDialogFragment d = LMPDatePickerDialogFragment.newInstance();
FragmentManager fm = ObstetricsFragment1.this.getSherlockActivity().getSupportFragmentManager();
d.show(fm, "dialog");
}
});
return view;
}
I had a similar problem loading a lesson project (https://developer.android.com/training/multiple-threads).
To resolve, I had to add an external jar (sdk/extras/android/support/v4/android-support-v4.jar).
Hope this helps.