How to handle button clicks using the XML onClick within Fragments

前端 未结 18 1546
旧时难觅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:20

    You can define a callback as an attribute of your XML layout. The article Custom XML Attributes For Your Custom Android Widgets will show you how to do it for a custom widget. Credit goes to Kevin Dion :)

    I'm investigating whether I can add styleable attributes to the base Fragment class.

    The basic idea is to have the same functionality that View implements when dealing with the onClick callback.

提交回复
热议问题