I have a fragment and in its layout I have a an area for two views. one is for list view. The other is for a map view.
the list view is simply a list view. the map view is a fragment that I commit once a button is clicked. So when I press that button for the first time, it takes around 2-3 seconds for it to replace the fragment in the dedicated view. In this time, all of the UI is just stuck. After that, the transition between list to map and vice versa is smooth.
how can that be overcome?
Layout's layout :
<RelativeLayout
....
<RelativeLayout
android:id="@+id/mapViewLayout"
android:layout_below="@id/restaurantListFragTxtNoResults"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
</RelativeLayout>
<RelativeLayout
android:id="@+id/listViewLayout"
android:layout_below="@id/restaurantListFragTxtNoResults"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/app_theme_color"
android:dividerHeight="4px">
</ListView>
...
</RelativeLayout>
...
</RelativeLayout>
on button click to toggle to map view :
mFragmentManager.beginTransaction()
.replace( R.id.mapViewLayout,
new MapFragment() ).commit();
layoutView.findViewById(R.id.restViewLayout).setVisibility(View.GONE);