【发布时间】:2023-03-21 10:06:01
【问题描述】:
在我的 Android 应用程序中,我有一个带有按钮的片段。单击按钮后,我将加载另一个带有 MapView 的片段。这一切都很好,但问题是一旦点击前一个 Fragment 的按钮,带有 Google Maps 的 Fragment 至少会持续 0.5 秒才能启动。你知道另一种加载谷歌地图而不会卡住片段事务的方法吗?
这是加载谷歌地图的片段
public class DetalleRuta extends android.support.v4.app.Fragment {
private GoogleMap googleMap;
private MapView mapView;
public DetalleRuta() {
// Required empty public constructor
}
@Override
public void onResume() {
mapView.onResume();
super.onResume();
}
@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_detalle_ruta, container, false);
//Inicio el mapa
mapView = (MapView)v.findViewById(R.id.mapa);
mapView.onCreate(savedInstanceState);
googleMap = mapView.getMap();
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
return v;
}
}
也许我的智能手机不够好,它是 BQ aquaris E4。
【问题讨论】:
-
您的智能手机是罪魁祸首..尝试在其他设备上测试您的应用..
-
好的,谢谢您的快速回复
标签: android google-maps maps fragment