Why won't @override work?
What is wrong with piece of code?
@Override
protected void onCreate(Bundle savedInstanceState) {
Eclipse states that @override cant be where it is. It says that 'Bundle' is wrong. I am lost.
Asked by: Rafael885 | Posted: 20-01-2022
Answer 1
it should be
@Override public void onCreate(Bundle savedInstanceState){
}
onCreate
is public, not protected.
Answer 2
So maybe the problem is compiler compliance level: 1.5 instead of 1.6 ?
@Baleisen which level is set for your project?
Answered by: Max845 | Posted: 21-02-2022Answer 3
I don't know much about the android framework but:
First make sure your class extends a Class such as (Activity) which contains onCreate. Then try to call super.onCreate, to double check that Class you are extending contains onCreate! You could be pointing to another class with the same name. Your compiler says that there is nothing to override, if you are sure it is wrong, then either your compiler is out dated or the framework.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//yourCode
}
Also if your extending and extended class, make sure, this method, I posted is in the class extending the class. It could freak out on this.
Answered by: David200 | Posted: 21-02-2022Answer 4
What your class extends ? And which android SDK version you're compiling ?
Answered by: Elise323 | Posted: 21-02-2022Answer 5
This has happened to me before and the problem was the Android SDK hadn't loaded into Eclipse fully.
Also, do you have this import in your file? The parent onCreate method is in Activity.
import android.app.Activity;
Answered by: Roman790 | Posted: 21-02-2022
Similar questions
java - Android @Override usage
This question already has answers here:
java - The Meaning of @override in Android Studio
This question already has answers here:
can i @Override an android method to change the parameter types?
this is what the code originally looks like:
@Override
public void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser){
...
}
i need it to be this:
@Override
public void onProgressChanged (SeekBar seekBar, float progress, boolean fromUser){
...
}
however when i change the int to a float i get an error saying that The method on...
java - Is it safe to comment out the "@Override"?
To get my code to compile - which contained the following:
public class ContactsActivity extends ListActivity implements AdapterView.OnItemClickListener {
Cursor mContacts;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Return all contacts, ordered by name
String[] projection = new String[] { ContactsContract.Contacts....
android - @Override problems
In my project, I'm having hundreds of errors because of the keyword @Override because I updated my Eclipse, JDK and all the components. This problem is because my team is using older versions. So is there any way I can ignore this error messages? If there is, how? Second option would be to revert back to older version of my jdk. I need some advice. Thanks.
android - field constant and @override
Im trying to elminate all errors for an android app developed using Eclipse..
"run_buton = (ToggleButton) findViewById(R.id.tbtn_runtoggle);
run_buton.setOnClickListener(this);
rb1 = (RadioButton)findViewById(R.id.rbtn_ch1);
rb2 = (RadioButton)findViewById(R.id.rbtn_ch2);"
These are part of my code in the .java file in the src file...however there are errors..eclipse sa...
java - Eclipse - setting to compiler 1.6 to avoid @Override errors not working?
I'm currently developing a small test project with Android and I get the infamous @Override error:
The method onBackPress() of type KvizActivity must override or implement a
supertype method.
Here is the code that causes it:
public class KvizActivity extends Activity {
/** onCreate(), onDestroy(), etc... */
@Override
public void onBackPress() {
...
java - @Override and Super
It seems to me that when you override methods you intend to modify their usefulness.
But why evoke the same method in the superclass (in the way in which it was originally written) if it does not interest me like that? That is, modifying the method and then calling the same method on the original way it seems to me that the first change was undone by the second. Where am I wrong?
android - Surface View canvas . @Override on key down
The onKeyDown method does not function. When i press the button the bitmap s does not move.
When it is done directly by putting j=j+5; inside canvas it works.
When did it directly in onkeydown j+5 then also it was'nt moving.
public class SmileyView extends SurfaceView implements SurfaceHolder.Callback {
public SmileyView(Context context, AttributeSet attrs) {
super(context, attrs);
...
android - Project @Override error
This question already has answers here:
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android