How to handle button clicks using the XML onClick within Fragments

前端 未结 18 1506
旧时难觅i
旧时难觅i 2020-11-22 01:41

Pre-Honeycomb (Android 3), each Activity was registered to handle button clicks via the onClick tag in a Layout\'s XML:

android:onClick=\"m         


        
18条回答
  •  清酒与你
    2020-11-22 02:06

    Your Activity is receiving the callback as must have used:

    mViewPagerCloth.setOnClickListener((YourActivityName)getActivity());
    

    If you want your fragment to receive callback then do this:

    mViewPagerCloth.setOnClickListener(this);
    

    and implement onClickListener interface on Fragment

提交回复
热议问题