onAttach(Activity) deprecated: where I can check if the activity implements callback interface

前端 未结 7 1040
再見小時候
再見小時候 2020-12-14 07:43

Before API 23 I used Fragment\'s onAttach methods to get my listener instance, then the reference is cleaned inside onDetach. ex:

@Override
public void onAtt         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 08:31

     public class MainActivity extends AppCompatActivity implements  topsection.TopSectionListener {
    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
     }
    
    
    
     public void createMeme(String top, String bottom){
        bottomsection fragmentbottom = (bottomsection) getSupportFragmentManager().findFragmentById(R.id.fragment2);
        fragmentbottom.setMemeText(top, bottom);
      }
     }
    

提交回复
热议问题