I cant find out why my findViewById
is not linking to the XML file and it is driving me nuts. The is is in the XML file but it is still not Finding it in the java MainActivity
file.
here is my 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<EditText
android:id="@+id/editCentimeters"
android:layout_width="wrap_content"
android:layout_height="27sp"
android:layout_alignLeft="@+id/editInches"
android:layout_alignTop="@+id/textCentimeters"
android:ems="5" >
<Button
android:id="@+id/buttonConvert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editInches"
android:layout_centerHorizontal="true"
android:layout_marginTop="98dp"
android:text="@string/convert" />
And here is my Java
EditText etCentimeters = (EditText) findViewById(R.id.editCentimeters);
Button buttonConvert = (Button) findViewById(R.id.buttonConvert);
I was facing the same issue. Just comment out the line which is throwing the error & BUILD the project once. Intellisense (ctrl + space) then will show you the IDs.