I have the following generic activity
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
public abstract class SingleFragmentActivity extends AppCompatActivity {
protected abstract Fragment createFragment();
.
.
.
and want to implement
import android.support.v4.app.Fragment;
public class PhotoDisplayActivity extends SingleFragmentActivity {
@Override
protected Fragment createFragment() {
return PhotoDisplayFragment.newInstance();
}
}
But this is throwing incompatible types: PhotoDisplayFragment cannot be converted to Fragment
. Changing the SingleFragmentActivity
return type to a PhotoDisplayActivity
would obviously defeat the purpose of it being generic.
What am I messing up here?
Thanks, Otterman