Hello I have a problem with commit fragment into DialogFragment I have simple dialogFragment...
public class CustomCalendarDialog extends DialogFragment {
public CustomCalendarDialog() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_custom_calendar, container);
FrameLayout frame = view.findViewById(R.id.Dialogcontainer1);
int id = frame.getId();
FragmentManager fragmentManager = ((FragmentActivity) getActivity()).getSupportFragmentManager();
Fragment customCalendarFragment = CustomCalendarFragment.newInstance();
fragmentManager.beginTransaction().replace(id, customCalendarFragment );
return view;
}
}
And have Fragment which can commit into activity with this lines
Fragment customCalendarFragment = CustomCalendarFragment.newInstance();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(frameLayout.getId(), customCalendarFragment ).commit();
with this lines in activity program work good.
Now I need replace this fragment into Dialog/Dialog Fragment.
I have layout fragment_custom_calendar.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000ff">
<FrameLayout
android:id="@+id/Dialogcontainer1"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</FrameLayout>
Inflate layout into dialog
View view = inflater.inflate(R.layout.fragment_custom_calendar, container);
variable container is null I don't know if it's ok or no.
View it's ok, On screen can see Blue layout (#0000ff) But I want see my fragment (Custom calendar)
Program not crashed on commit lines
FrameLayout frame = view.findViewById(R.id.Dialogcontainer1);
int id = frame.getId();
FragmentManager fragmentManager = ((FragmentActivity) getActivity()).getSupportFragmentManager();
Fragment customCalendarFragment = CustomCalendarFragment.newInstance();
fragmentManager.beginTransaction().replace(id, customCalendarFragment );
frame is not null id is not null customCalendarFragment is not null but I cant see it.
I create fragment :
public static Fragment newInstance() {
return (Fragment) new CustomCalendarFragment();
}
My calling dialog from MainActivity
CustomCalendarDialog cdd = new CustomCalendarDialog();
cdd.show(getFragmentManager(), "TAG");
I need this fragment in dialog :( I don't know if commit fragment is posible in normal Dialog if yes please link me and i will look.
Thanks any idea