所以我现在在我的程序中唯一的布局就是这个activity_main文件。我有一个MainActivity类。我在保存xml文件时遇到了构建错误,并且还没有生成我的R文件。我读取的R文件没有生成与xml错误有关。即使在构建时,错误也不会被我的cml中的eclipse捕获。我已经包含了我的字符串xml文件,布局文件和android清单。非常感谢帮助,谢谢。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">django mouse</string>
<string name="title_activity_main">MainActivity</string>
<string name="hello_world">Hello world!</string>
<string name="welcome_header">Welcome to Django</string>
<string name="start_instructions">To begin enter your local ip address and then click the start button</string>
<string name="pebb_accel_header">Pebble Accelerometer Data</string>
<string name="main_x_coordinate">X: </string>
<string name="main_y_coordinate">Y: </string>
<string name="main_z_coordinate">Z: </string>
<string name="up_button">up</string>
<string name="down_button">down</string>
<string name="left_button">left</string>
<string name="right_button">right</string>
<string name="click_button">click</string>
<string name="start_button">start</string>
</resources>
activity_main
<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>`
Android Manifest
<?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>
答案 0 :(得分:0)
Button
activity_main.xml
标记
colors.xml
?答案 1 :(得分:0)
正如Stephan所提到的,添加/&gt;持续Button标签并执行清理和重建项目