A
A
Arman Dendibaev2017-10-07 14:49:54
Java
Arman Dendibaev, 2017-10-07 14:49:54

What is the problem in android studio?

59d8bf1d139e8643277062.png
Help solve the problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ivametal, 2017-10-07
@ivametal

You are trying to execute code outside of runtime.
Any program always has an entry point, in activation the entry point is onCreate (), the system starts executing the commands written in the onCreate () method sequentially. Do not forget that this is still Android, so the system will make some calls on its own (onResume(), for example).
Everything is correctly done with addListenerOnButton (), because the method call is in the body of another method.
Further, the call of the listener setup method is not in the body of another method, but in the body of the class (in which the description is made, but not the call). You just need to put .setOnClickListener() in the body of the AddListenerOnButton() method

Y
Yuri, 2017-10-07
@YuryBorodkin

Move the selection to a lifecycle method like OnCreate(Bundle savedInstanceState) .

A
aspid-d, 2017-10-08
@aspid-d

take the "}" that comes after AddListenerOnButton and move it to the very bottom

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question