I’m trying out Android programming for the first time since I just finished reading the Head First Java book. I’m going through the Notepad Tutorial When I import the files for the project, my R class is not generated. I assume that is because of the errors I’m getting in one of my xml files. I’m using API 7
The error goes as follows:
Error: String types not allowed (at ‘layout_height’ with value ‘match_parent’). note_edit.xml /Notepadv2/res/layout line 3 Android AAPT Problem
Here’s my xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title" />
<EditText android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/body" />
<EditText android:id="@+id/body" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical" />
<Button android:id="@+id/confirm"
android:text="@string/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
What version are you using? 2.1 will not support the
match_parentAnd, also If your project’sresfolder contains any errors means, yourR.javafile will not generate untill you will clear the errors in yourxmlfiles.So, just Change the height as
fill_parentinstead ofmatch_parentor just change your project target as 2.2After, done these things. Just clean your project and Run. Hope this helps you.