1

So I've been following this Android Tutorial (Youtube) by Derek Banas. Trying to learn to make a NavigationDrawer.

I run into onAttach() being deprecated. I looked at this Stack Overflow link but I'm a beginner in AS and can't understand if it's correct (mainly due to me not sure if I have to instantiate MTitle, mCalled, mHost,etc) and how I can possibly implement it, in my app.

onAttach code:

public void onAttatch(Activity activity) {
    super.onAttach(activity);
    ((MainActivity)activity).onSectionAttached(1);
}

public void onSectionAttached(int number) {
    switch(number) {
        case 1:
            mTitle = getString(R.string.title_section1);
            break;
    }
Community
  • 1
  • 1
CodieneUp
  • 11
  • 3

1 Answers1

0

Try

public void onAttach(Context context){
     super.onAttach(context);
  ...
}