integrated this library SlideDateTimePicker
Code
new SlideDateTimePicker.Builder(getSupportFragmentManager())
.setListener(listener)
.setInitialDate(new Date())
.build()
.show();
Error
Log 1
java.lang.IllegalStateException: Fragment DateFragment{8cb3765 #0 id=0x7f12026c android:switcher:2131886700:0} declared target fragment
that does not belong to this FragmentManager
Log 2
java.lang.IllegalStateException: View with id 2131886700: com.github.jjobes.slidedatetimepicker.CustomViewPager#onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:18800)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18788)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1191)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
in Library code able to change 2 classes 1. TimeFragment
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try {
mCallback = (TimeChangedListener) getParentFragment();
} catch (ClassCastException e) {
throw new ClassCastException("Calling fragment must implement " + "TimeFragment.TimeChangedListener interface");
}
}
2.Change following code in DateChangedListener
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try {
mCallback = (DateChangedListener) getParentFragment();
} catch (ClassCastException e) {
throw new ClassCastException("Calling fragment must implement " + "DateFragment.DateChangedListener interface");
}
}
3.SlideDateTimeDialogFragment
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
DateFragment dateFragment = DateFragment.newInstance(
mTheme,
mCalendar.get(Calendar.YEAR),
mCalendar.get(Calendar.MONTH),
mCalendar.get(Calendar.DAY_OF_MONTH),
mMinDate,
mMaxDate);
// dateFragment.setTargetFragment(SlideDateTimeDialogFragment.this, 100);
return dateFragment;
case 1:
TimeFragment timeFragment = TimeFragment.newInstance(
mTheme,
mCalendar.get(Calendar.HOUR_OF_DAY),
mCalendar.get(Calendar.MINUTE),
mIsClientSpecified24HourTime,
mIs24HourTime);
// timeFragment.setTargetFragment(SlideDateTimeDialogFragment.this, 200);
return timeFragment;
default:
return null;
}
}
}
Here due to set setTargetFragment
not able to load Fragment, need to comment and change getTargetFragment();
to getParentFragment()
// timeFragment.setTargetFragment(SlideDateTimeDialogFragment.this, 200);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With