@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
activitycomander = (TopSectionListener) activity;
}catch (ClassCastException e){
throw new ClassCastException(activity.toString());
}
}
This is the code of my java class linking with MainActivity.
There is issue with onAttach
method in Android Studio. It shows as strike-through with the message:
onAttach
(android.app.activity
) is deprecated:
I'm also having a second issue in MainActivity:
public void createMeme(String top, String bottom){
bottomsection fragmentbottom = (bottomsection) getSupportFragmentManager().findFragmentById(R.id.fragment2);
fragmentbottom.setMemeText(top, bottom);
}
topsection
and bottomsection
are the names of my java classes, they are highlighted red with the message cannot resolve method
.
I have done a clean rebuild on my project and checked the option to add or remove the imports automatically.