How to make a callback between Activity and Fragment?

后端 未结 3 1033
孤独总比滥情好
孤独总比滥情好 2020-12-05 10:54

I have this interface in my activity.

public interface LogoutUser {
    void logout();
}

My fragment implements this interface, so in my fr

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 11:47

    Android Fragments - Communicating with Activity

    You need to get a reference to your fragment with getFragmentById() or getFragmentByTag()

    getFragmentManager().findFragmentById(R.id.example_fragment);
    

提交回复
热议问题