Error: The Method Oncreate(bundle) In The Type Alertfunction Is Not Applicable For The Arguments ()
Solution 1:
You don't need to call onCreate()
explicitely. Once you declare an instance of a class, if it has the onCreate()
class, it will be automatically called at the appropiate time.
If you override that class, always be sure to declare the @Override
statement above it, this will make sure you're overriding the correct function because if you don't, and you don't specify the correct parameters that the former method has, it will not be called and you'll think it does.
Also, it's a good idea to call super.onCreate(savedInstance)
as the first line of your overriden method.
---- EDIT ----
As said above, onCreate()
is called on the object creation, i.e., when you declare: alertFunction alertClass = new alertFunction();
.
If this is something you want to call several times, put the content in a public function inside your class and call it from onCreate()
and from the outside when needed. For instance:
publicvoidmyFunction() {
// Put here the current code of onCreate()
...
}
@OverridepublicvoidonCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
myFunction();
}
And then if you need to call it again from outside your class, do the following:
alertClass.myFunction();
Post a Comment for "Error: The Method Oncreate(bundle) In The Type Alertfunction Is Not Applicable For The Arguments ()"