gpt4 book ai didi

java - XML 膨胀错误

转载 作者:行者123 更新时间:2023-12-01 15:02:27 24 4
gpt4 key购买 nike

当我尝试运行我的应用程序时,遇到了这个非常奇怪的错误。我认为是由于我的标签。这是错误:

11-18 14:45:27.093: E/AndroidRuntime(680): FATAL EXCEPTION: main
11-18 14:45:27.093: E/AndroidRuntime(680): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.os.Handler.dispatchMessage(Handler.java:99)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.os.Looper.loop(Looper.java:123)
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-18 14:45:27.093: E/AndroidRuntime(680): at java.lang.reflect.Method.invokeNative(Native Method)
11-18 14:45:27.093: E/AndroidRuntime(680): at java.lang.reflect.Method.invoke(Method.java:521)
11-18 14:45:27.093: E/AndroidRuntime(680): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-18 14:45:27.093: E/AndroidRuntime(680): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-18 14:45:27.093: E/AndroidRuntime(680): at dalvik.system.NativeStart.main(Native Method)
11-18 14:45:27.093: E/AndroidRuntime(680): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.la

这是我的 xml 文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#ccc" >

<TextView
android:id="@+id/titleTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Bytes"
android:textSize="20dp" />
</LinearLayout>

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

<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" >
</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>

</RelativeLayout>

还有我的 OnCreate 方法:

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setup();

TabSpec ts = tabHost.newTabSpec("Home").setIndicator("Home").setContent(new Intent().setClass(this,MainActivity.class));
tabHost.addTab(ts);
ts = tabHost.newTabSpec("Quests").setIndicator("Quests").setContent(new Intent().setClass(this,Jobs.class));
tabHost.addTab(ts);

tabHost.setCurrentTab(0);

我以前从未见过这个错误。由于某种原因,我的 xml 文件出现膨胀问题?

最佳答案

您正在通过尝试加载来创建无限循环:
MainActivity 与选项卡中的 MainActivity、 与选项卡中的 MainActivity、 与选项卡中的 MainActivity、 与选项卡中的 MainActivity、 与选项卡中的 MainActivity、 选项卡中的 MainActivity,选项卡中包含 MainActivity,选项卡中包含 MainActivity,选项卡中包含 MainActivity,

这是麻烦的一行:

TabSpec ts = tabHost.newTabSpec("Home").setIndicator("Home").setContent(new Intent().setClass(this,MainActivity.class));

我感觉你的完整 LogCat 显示根本原因是 StackOverflowException...

无论如何,您需要创建一个新类,将其命名为“Home”,其中 MainActivity 加载选项卡,而 Home 是您的默认屏幕。

关于java - XML 膨胀错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13445457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com