gpt4 book ai didi

android - 没有 XML 内容。请在您的文档中添加 Root View 或布局

转载 作者:太空宇宙 更新时间:2023-11-03 11:38:15 26 4
gpt4 key购买 nike

我正在开发一个安卓应用程序。我是 XML 的新手。我收到消息说“没有 XML 内容。请向您的文档添加 Root View 或布局”。下面给出了 XML 代码。请帮忙

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ref"
android:textSize="15dp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ref2"
android:textSize="15dp"/>

<EditText
android:id="@+id/uname"
android:layout_width="150dp"
android:layout_height="25dp"
android:inputType="text"
android:ems="5" >

<requestFocus />
</EditText>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ref3"
android:textSize="15dp"/>

<EditText
android:id="@+id/pwd"
android:layout_width="150dp"
android:layout_height="25dp"
android:inputType="text"
android:ems="5" />

<Button
android:layout_width="60dp"
android:layout_height="35dp"
android:text="@string/ref"
android:id="@+id/bLogin" />
</LinearLayout>

----主要 Activity 代码---

package com.android.disasterAlertApp;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class MainActivity extends Activity {
/** Called when the activity is first created. */
Button login;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
login =(Button) findViewById(R.id.bLogin);
}
}

----Manifest----
[2012-04-17 00:34:20 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-04-17 00:34:20 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here.
[2012-04-17 00:34:20 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2012-04-17 01:05:59 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-04-17 01:05:59 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here.
[2012-04-17 01:05:59 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2012-04-17 01:11:14 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-04-17 01:11:14 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here.
[2012-04-17 01:11:14 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2012-04-17 01:14:56 - Disaster Alert App] ------------------------------
[2012-04-17 01:14:56 - Disaster Alert App] Android Launch!
[2012-04-17 01:14:56 - Disaster Alert App] Connection with adb was interrupted.
[2012-04-17 01:14:56 - Disaster Alert App] 0 attempts have been made to reconnect.
[2012-04-17 01:14:56 - Disaster Alert App] You may want to manually restart adb from the Devices view.
[2012-04-17 01:17:27 - Disaster Alert App] Error in an XML file: aborting build.
[2012-04-17 01:37:10 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-04-17 01:38:42 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-04-17 01:38:42 - Disaster Alert App] res\layout\main.out.out.xml:0: Originally defined here.
[2012-04-17 01:38:42 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.out.xml:1: error: Error parsing XML: no element found
[2012-04-17 01:39:28 - Disaster Alert App] Error in an XML file: aborting build.

最佳答案

哦——看到“main.out.xml”了吗?当您使用 eclipse 启动 XML 文件时会发生这种情况。只需删除“out”xml 并保留 main.xml

请务必在点击“播放”时选择/正在编辑 .java 文件,否则 eclipse 将生成“out.xml”并无法启动。

关于android - 没有 XML 内容。请在您的文档中添加 Root View 或布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10181066/

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