I get this irritating id cannot be resolved or is not a field
with R.id only, and not R.layout. When I click on the x it says no suggestions, and it is referencing the field correctly (blue & italic).
I've tried cleaning, building, restarting, deleting R, fixing imports. Nothing works.
Following is my code :
package com.example.helloworld;
import com.example.helloworld.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class NameGetter extends Activity implements OnClickListener
{
@Override
public void onCreate(Bundle b){
Button btn;
super.onCreate(b);
setContentView(R.layout.namegetter);
btn = (Button) findViewById(R.id.button1);
if (btn != null){
btn.setOnClickListener(this);
}
}
@Override
public void onClick(View v) {
String name = "";
Intent i = new Intent(this, MainActivity.class);
EditText et = (EditText) findViewById(R.id.editText1);
if (et != null){
name = et.getText().toString();
}
i.putExtra("n", name);
this.startActivity(i);
}
}
How can I determine the source of this error?