【发布时间】:2017-01-02 19:56:27
【问题描述】:
我有一个片段,在它的布局中我有一个用于两个视图的区域。一种是用于列表视图。另一个用于地图视图。
列表视图只是一个列表视图。 地图视图是我在单击按钮后提交的片段。 因此,当我第一次按下该按钮时,它需要大约 2-3 秒才能替换专用视图中的片段。在这个时候,所有的 UI 都只是卡住了。 之后,list 到 map 之间的转换是平滑的。
如何克服?
布局的布局:
<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>
点击按钮切换到地图视图:
mFragmentManager.beginTransaction()
.replace( R.id.mapViewLayout,
new MapFragment() ).commit();
layoutView.findViewById(R.id.restViewLayout).setVisibility(View.GONE);
【问题讨论】:
标签: android user-interface replace transactions fragment