Call an activity method from a fragment

前端 未结 14 791
广开言路
广开言路 2020-11-22 09:08

Trying to call a method in my activity from a fragment. I want the fragment to give the method data and to get the data when the method return. I want to achieve similar to

14条回答
  •  無奈伤痛
    2020-11-22 09:31

    This is From Fragment class...

    ((KidsStoryDashboard)getActivity()).values(title_txt,bannerImgUrl);
    

    This Code From Activity Class...

     public void values(String title_txts, String bannerImgUrl) {
        if (!title_txts.isEmpty()) {
    
    //Do something to set text 
        }
        imageLoader.displayImage(bannerImgUrl, htab_header_image, doption);
    }
    

提交回复
热议问题