有两个活动: Map Yandex。
public class MapsActivity extends AppCompatActivity {
private MapView mapview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapKitFactory.setApiKey("censored");
MapKitFactory.initialize(this);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
mapview = (MapView)findViewById(R.id.mapview);
mapview.getMap().move(
new CameraPosition(new Point(55.751574, 37.573856), 11.0f, 0.0f, 0.0f),
new Animation(Animation.Type.SMOOTH, 0),
null);
}
@Override
protected void onStop() {
super.onStop();
mapview.onStop();
MapKitFactory.getInstance().onStop();
}
@Override
protected void onStart() {
super.onStart();
mapview.onStart();
MapKitFactory.getInstance().onStart();
}
还有一个,开始加载屏幕。她的布局:
……
<include layout="@layout/activity_maps"
android:layout_width="match_parent"
android:layout_height="300dp"/>
……
抛出错误:
android.view.InflateException: Binary XML file line #23 in com.rdv.slcard:layout/fragment_home: Binary XML file line #8 in com.rdv.slcard:layout/activity_maps: Error inflating class com.yandex.mapkit.mapview.MapView
Caused by: android.view.InflateException: Binary XML file line #8 in com.rdv.slcard:layout/activity_maps: Error inflating class com.yandex.mapkit.mapview.MapView
Caused by: java.lang.reflect.InvocationTargetException
我究竟做错了什么?
更新
第一个活动的布局
<com.yandex.mapkit.mapview.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.maps.MapsActivity"
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
更新 V.2.0
当然,您最好浏览片段,但这对夫妇说错话了
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapview"
android:name="com.yandex.mapkit.mapview.MapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.maps.MapsActivity"
/>
当我改变时:
<com.yandex.mapkit.mapview.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.maps.MapsActivity"
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
在常规 Button 或 TextView 上 - 一切都很好。我什么都听不懂。不可能是 Yandex 没有考虑到<include>
Yandex 地图不支持
<include>
地图活动。尽可能不要使用 Yandex 地图。它有一堆门框,很少的文档,没有支持,还有一堆其他可怕的东西。GoogleMap +50$ 对于好的项目来说要好得多