Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 生成android XML布局时出错,r文件未生成_Java_Android_Xml_Eclipse - Fatal编程技术网

Java 生成android XML布局时出错,r文件未生成

Java 生成android XML布局时出错,r文件未生成,java,android,xml,eclipse,Java,Android,Xml,Eclipse,所以我现在程序中唯一的布局就是这个活动的主文件。我有一个主要的活动课。我在保存xml文件时遇到一个生成错误,而且我的R文件也没有生成。我读到没有生成的R文件与一个xml错误有关。即使在构建cml时,eclipse也不会捕捉到这些错误。我已经包括了字符串xml文件、布局文件和android清单。非常感谢您的帮助,谢谢 字符串XML文件 主要活动 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

所以我现在程序中唯一的布局就是这个活动的主文件。我有一个主要的活动课。我在保存xml文件时遇到一个生成错误,而且我的R文件也没有生成。我读到没有生成的R文件与一个xml错误有关。即使在构建cml时,eclipse也不会捕捉到这些错误。我已经包括了字符串xml文件、布局文件和android清单。非常感谢您的帮助,谢谢

字符串XML文件 主要活动

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="20dp"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame" >

    <TextView
        android:id="@+id/welcome_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:gravity="center_horizontal"
        android:text="@string/welcome_header"
        android:textColor="@color/Black"
        android:textSize="22sp" />

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

        <TextView
            android:id="@+id/start_stop_instructions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="75dp"
            android:text="@string/start_instructions"
            android:textColor="@color/Black"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/welcome_sub_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/start_stop_instructions"
            android:paddingTop="16dp"
            android:text="@string/pebb_accel_header"
            android:textColor="@color/Black"
            android:textSize="18sp" />

        <LinearLayout
            android:id="@+id/accel_data"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/pebb_accel_header"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/main_x_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_x_coordinate"
                android:textColor="@color/Black" />

            <TextView
                android:id="@+id/main_y_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_y_coordinate"
                android:textColor="@color/Black" />

            <TextView
                android:id="@+id/main_z_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_z_coordinate"
                android:textColor="@color/Black" />
        </LinearLayout>

        <Button
            android:id="@+id/up_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/accel_data"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="32dp"
            android:text="@string/up_button" />

        <Button
            android:id="@+id/down_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/up_button"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="48dp"
            android:text="@string/down_button" />

        <Button
            android:id="@+id/left_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toLeftOf="@id/up_button"
            android:text="@string/left_button" />

        <Button
            android:id="@+id/right_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toRightOf="@id/up_button"
            android:text="@string/right_button" />

        <Button
            android:id="@+id/click_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toLeftOf="@id/right_button"
            android:layout_toRightOf="@id/left_button"
            android:text="@string/click_button" />
    </RelativeLayout>

    <Button
        android:id="@+id/main_start_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="@string/start_button"

</RelativeLayout>`
安卓清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.housedroid.djangomouse"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.housedroid.djangomouse.MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
检查activity_main.xml中的最后一个按钮标记 您是否定义了类似colors.xml的内容?
正如Stephan提到的,将/>添加到最后一个按钮标记并执行清理和重建项目

您的最后一个按钮缺少关闭按钮/>请更正错误,执行清理和重建项目。我很惊讶Eclipse没有显示错误,在activity_main下应该有一条弯曲的红色下划线。谢谢!这是问题之一,我还发现了一些其他问题。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.housedroid.djangomouse"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.housedroid.djangomouse.MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>