【问题标题】:Unfortunately app has stopped in Android Emulator - Eclipse不幸的是,应用程序已在 Android 模拟器中停止 - Eclipse
【发布时间】:2012-10-22 15:52:16
【问题描述】:

在 Eclipse 的模拟器上检查我的 Android 应用程序时,我似乎遇到了一些问题。当应用准备好运行时,我收到一条消息:

很遗憾,应用名称已停止。

代码如下:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <Textview
                        android:id="@+id/textview1"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:text="Welcome to Ambius" >
                     </Textview>

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</FrameLayout>

【问题讨论】:

  • 这不是代码,在这里发布你的 onCreate() 方法以及 logcat 堆栈跟踪。
  • 看起来这个问题被要求提供更多代码。因此它可以因为缺少 minimal reproducible example 而被关闭。

标签: java android eclipse android-tabhost android-tabs


【解决方案1】:

为了使选项卡工作,您还需要一些 java 文件中的代码。

看看这些例子:

要启用 LogCat,请转到 Window > Show View > LogCat(如果它不可见,请按其他...它在 Android 下分组)

【讨论】:

    猜你喜欢
    • 2014-08-04
    • 2012-07-12
    • 2012-01-08
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 2014-12-06
    • 2014-09-22
    • 2015-08-10
    相关资源
    最近更新 更多