Reputation: 617
When I import android.R
I get Error_1 and the Error_2 is solved. So, how do I solve Error_1. I've tried changing import android.R
--> import com.example.testing.R
. However it is still not working.
Even my login.xml seems to be find. No error. I've also tried cleaning the project. Still nothing happens.
LoginActivity.java
package com.example.testing;
import android.R; //Error_1 : Don't include android.R here; use a fully qualified name for each usage instead
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class LoginActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setting default screen to login.xml
setContentView(R.layout.login); //Error_2 : login cannot be resolved or is not a field
TextView registerScreen = (TextView) findViewById (R.id.link_to_register);
//Listening to register new account link
registerScreen.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
//Switching to Register Screen
Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(i);
}
});
}
}
This is my login.xml
login.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<LinearLayout android:id="@+id/header"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip">
</LinearLayout>
<!-- Footer -->
<LinearLayout android:id="@+id/footer"
android:orientation="horizontal"
android:contentDescription="@string/description"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:background="@layout/footer_repeat"
android:layout_alignParentBottom="true">
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/name" />
<EditText android:id="@+id/editText1"
android:hint="@string/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="20dip"
android:singleLine="true"/>
<!-- Password Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/password"/>
<EditText android:id="@+id/editText2"
android:hint="@string/edit_message1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:inputType="textVisiblePassword"/>
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/login"/>
<TextView android:id="@+id/link_to_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:layout_marginBottom="40dip"
android:text="@string/loginDesc"
android:gravity="center"
android:textSize="20sp"
android:textColor="#0b84aa"/>
</LinearLayout>
<!-- Login Form Ends -->
</RelativeLayout>
</ScrollView>
Upvotes: 2
Views: 6548
Reputation: 48
Firstly remove import android.R and then
Step 1. worked for me.
Upvotes: 1
Reputation: 53
you should import com.example.testing.R remove import android.R and check login.xml.
Upvotes: 1
Reputation: 526
NOTE: you might have an issue of having a .out file in your res folder, this is a bug of eclipse that occurs when you try to compile the project while a XML fiole is open. If so delete it and try
Upvotes: 2