【发布时间】:2020-02-06 15:16:54
【问题描述】:
我正在尝试制作地图应用程序。使用按钮链接到 MapActivity 类,但当我按下按钮时应用程序立即崩溃。请告知,如果需要更多信息来解决错误,请随时向我提出要求。
MapActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map); //<-- logcat points at this line
}
活动地图
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapActivity">
<include layout="@layout/content_map" /> //<-- this is line 12
</androidx.coordinatorlayout.widget.CoordinatorLayout>
content_map.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MapActivity"
tools:showIn="@layout/activity_map"*>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.skyfishjy.library.RippleBackground
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ripple_bg"
app:rb_color="#0099CC"
app:rb_radius="32dp"
app:rb_rippleAmount="4"
app:rb_duration="3000"
app:rb_scale="6">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:translationY="-18dp"
android:src="@drawable/ic_placeholder"/>
</com.skyfishjy.library.RippleBackground>
<com.mancj.materialsearchbar.MaterialSearchBar
style="@style/MaterialSearchBarLight"
app:mt_speechMode="false"
app:mt_hint="Search a place"
app:mt_maxSuggestionsCount="10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/searchBar"
android:layout_margin="16dp"
app:mt_navIconEnabled="true"
android:elevation="5dp"
android:outlineProvider="bounds"
app:mt_placeholder="Search a place"/>
<Button
android:id="@+id/btn_find"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Find Restaurants"
android:textColor="#FFFFFF"
android:background="@color/colorPrimary"
android:layout_margin="16dp"
android:textStyle="bold"/>
</RelativeLayout>
【问题讨论】:
-
构建 gradle 依赖项{ implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' }
-
content_map,相对布局在开始标记处有一个 *。
-
我认为我在发布问题时不小心添加了它,对不起,我将编辑帖子
-
确切的异常消息是什么?
-
java.lang.RuntimeException:无法启动活动 ComponentInfo{com.example.superapp/com.example.superapp.MapActivity}:android.view.InflateException:com 中的二进制 XML 文件第 12 行。 example.superapp:layout/activity_map:com.example.superapp:layout/content_map 中的二进制 XML 文件第 12 行:膨胀类片段时出错
标签: java android fatal-error