Reputation: 1185
For some reason, the "id" in the argument is underlined in red and is "not resolved and or not a field"
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.widget.Button;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button toggleButton = (Button)findViewById(R.id.toggleButton);
toggleButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
}
});
}
}
Upvotes: 1
Views: 4954
Reputation: 1851
It is a problem faced in eclipse IDE. I had this problem
Check if any of the above is your problem. May be it will help
Cleaning and building the project might also help you
Upvotes: 1
Reputation: 2176
Check your gen[Generated Java Files] folder in package explorer.
It may be empty, try
Project --> Clean
This will Generate files
Hope This Helps
Upvotes: 2
Reputation: 16354
It is one of the problems everyone faces with EclipseIDE. Clean your project and build it once again.
P.S. : Also make sure that the id of the Button in your mail.xml is android:id="@+id/toggleButton"
Upvotes: 1