title: activity cannot be resolved or is not a field
body: <p>i'm a beginner Android developer. When I try to run my Application this error appears "</p>
  
  <pre><code>activity_prima cannot be resolved or is not a field PrimaActivity.java  /esempio3/src/com/example/esempio3  line 19 Java Problem ".  
  and also "activity_seconda cannot be resolved or is not a field SecondaActivity.java    /esempio3/src/com/example/esempio3  line 11 Java Problem"
  </code></pre>
  
  <p>I have already put my activities in the manifest.xml but something goes wrong because my R.txt desappears very often. Here there are my java  and xlm files .</p>
  
  <p>This is my <strong>first activity java file.</strong> </p>
  
  <pre><code>package com.example.esempio3;
  
  import android.R;
  import android.support.v7.app.ActionBarActivity;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.app.Activity;
  
  public class PrimaActivity extends Activity {
  
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_prima);
  
  Button bottone= (Button)findViewById(R.id.bott1);
  bottone.setOnClickListener(new View.OnClickListener()
  {
  public void onClick(View view) {
       Intent intent = new Intent(PrimaActivity.this,       SecondaActivity.class);
       startActivity(intent);      
       finish();
  }
  });
  }
  
  
  }
  </code></pre>
  
  <p>This is my <strong>xml file</strong>.</p>
  
  <pre><code>&lt;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:background="@drawable/sfondo1"
  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="com.example.esempio3.PrimaActivity" &gt;
  
  
  &lt;ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/img1"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="27dp"
      android:src="@drawable/batman3" /&gt;
  
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/imageView1"
      android:layout_marginTop="70dp"
      android:layout_centerInParent="true"
      android:text="Benvenuto nella mia App"
      android:textColor="#FFA07A" /&gt;
  
  
  
  
  &lt;Button
      android:id="@+id/bott1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="70dp"
      android:layout_below="@+id/img1"
      android:layout_above="@+id/bott2"
      android:layout_centerInParent="true"
      android:onClick="Login"
      android:text="Login" /&gt;
  
  &lt;Button
      android:id="@+id/bott2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="101dp"
      android:onClick="Registrati"
      android:text="Registrati" /&gt;
  
  &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"
      android:text="TextView" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here there is my <strong>second activity java file</strong>.</p>
  
  <pre><code>package com.example.esempio3;
  
  import android.R;
  import android.app.Activity;
  import android.os.Bundle;
  
  public class SecondaActivity extends Activity{
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_seconda);
  }
  
  
  
  
  }
  </code></pre>
  
  <p>my <strong>xml file</strong> is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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:background="@drawable/sfondo1"
  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="com.example.esempio3.SecondaActivity" &gt;
  
  &lt;TableLayout 
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_centerInParent="true"&gt;
  &lt;TableRow
      android:layout_marginTop="100dp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#F5F5DC"
      android:text="Username:"/&gt;
       &lt;EditText
      android:layout_height="wrap_content"
      android:inputType="text"
      android:id="@+id/username" /&gt;
  &lt;/TableRow&gt;
  
   &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#F5F5DC"
      android:text="Password:"/&gt;
       &lt;EditText
      android:layout_height="wrap_content"
      android:inputType="text"
      android:id="@+id/password" /&gt;
  &lt;/TableRow&gt;
  
   &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#F5F5DC"
      android:text="Indirizzo email:"/&gt;
       &lt;EditText
      android:layout_height="wrap_content"
      android:inputType="text"
      android:id="@+id/mail" /&gt;
  &lt;/TableRow&gt;
  
   &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="#F5F5DC"
      android:text="Nome:"/&gt;
       &lt;EditText
      android:layout_height="wrap_content"
      android:inputType="text"
      android:id="@+id/nome" /&gt;
  &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>My <strong>manifest</strong> is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.esempio3"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="21" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name=".PrimaActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
              &lt;activity
          android:name=".SecondaActivity"
           &gt;
      &lt;/activity&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks in advance for your help.</p>