【问题标题】:App Crashes when MainActivity extended with FragmentActivity [closed]使用 FragmentActivity 扩展 MainActivity 时应用程序崩溃 [关闭]
【发布时间】:2013-01-02 07:12:49
【问题描述】:
如果我的主要活动是 FragmentActivity,我的 android 应用程序会崩溃。
关于如何解决这个问题的任何想法?
public class MainActivity extends FragmentActivity {
//...
}
【问题讨论】:
标签:
android
android-fragmentactivity
【解决方案1】:
原来我只需要将我的片段包装在 activity_main.xml 中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>