1

A member on my team generated stub fragments in Android Studio, and onAttach(Context context) was automatically generated. However, the compiler reports the following errors in my code, shown below:

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class TestFragment extends Fragment {
    ...
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }
}
  1. error: method does not override or implement a method from a supertype

  2. error: incompatible types: Context cannot be converted to Activity

Why am I getting these error messages at compile time?

Jack
  • 5,354
  • 2
  • 29
  • 54
bko
  • 111
  • 3
  • I wonder if this issue is related. What is the device api level you are compiling for? https://stackoverflow.com/q/32083053/631051 – Ellen Spertus Apr 26 '19 at 14:43

0 Answers0