I have a problem with Android code:
This piece of code works perfectly:
CalendarDialogFagment dialog = new CalendarDialogFagment();
dialog.setTargetFragment(this, 0);
dialog.show(getActivity().getSupportFragmentManager(), "dialog_calendar");
But when I try to show it like a fragment (in tablet-version) it becomes very laggy and slow, taking large delays while updating fragment's layout.
Here is the code:
if (calendarContainer == null)
calendarContainer = getActivity().findViewById(R.id.games_calendar_container);
boolean isShown = calendarContainer.isShown();
if (!isShown) {
calendarContainer.setVisibility(View.VISIBLE);
if (calendarFragment == null) {
calendarFragment = new CalendarDialogFagment();
calendarFragment.setTargetFragment(this, 0);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.add(R.id.games_calendar, calendarFragment, "tag");
ft.commit();
getActivity().getSupportFragmentManager().executePendingTransactions();
}
}
else{
calendarContainer.setVisibility(View.GONE);
calendarContainer = null;
}
}
XML-file:
<LinearLayout
android:id="@+id/games_calendar_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stagelayout"
android:orientation="vertical"
android:visibility="gone"
android:weightSum="100" >
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="95" />
<LinearLayout
android:id="@+id/games_calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5"
android:background="@color/dark_gray" >
</LinearLayout>
</LinearLayout>
So, what the problem may be? Thanks a lot for your answers.