R
R
robert_n2016-10-19 17:41:24
Java
robert_n, 2016-10-19 17:41:24

How to add (override) a method in an activity after adding this method in the interface?

Hello! The essence of the problem:
I created an interface and 2 activities that inherit this interface:

public interface MyInterface
{
  void method_1(int arg1)
}

public class OneActivity extends AppCompatActivity implements MyInterface {
  @Override
    public void method_1(int arg1) {
        //
    }
}

public class TwoActivity extends AppCompatActivity implements MyInterface {
  @Override
    public void method_1(int arg1) {
        //
    }
}

If I want to add a new method to the interface, then I have to run the application, after which in Messages Gradle Build I get a list of errors that my new method added to the interface was not overridden in the activity. I go to each Activity, click Alt + Enterand select the very method that needs to be overridden. This is an example, in a real project I currently have one basic interface for 3 activities and 10 fragments. Adding a new method gives me pain..
Can you please tell me if Androd Studio has the ability to automatically generate this code? Those. I create a method in an interface, and it would automatically be added to all activities that inherit from this interface.
PS A new method is not always needed in all activities and fragments, ie. his body is empty. But creating another interface for this method does not make sense.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question