Altering the enabled state of an Android composite control while maintaining its style settings -


I have a custom button that I have implemented as a composite control that is composed of:

  • A FrameLayout in the Root, which is styled with @Android: in order to see style / widget.Holo.Button and to work like a button;
  • Two textViews as the above mentioned FrameLayout, configurable with duplicateParentState = true is that they will appear disabled if I enable it on FrameLayout on the wrong set

    Sorting XML looks like this:.

      & lt; FrameLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" style = "@Android: Style / Widget.Holo." Android: id = "@ + id / layout_button" & gt; & Lt; Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "placeholder" android: layout_gravity = "center_horizontal | top" android: duplicateParentState = "true" Android: id = "@ + id / text_button1" Android : Text size = "24 sp /" & Lt; Android: id = "@ + id / text_button2" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: text = "placeholder" android: layout_gravity = "center_horizontal | bottom" Android: duplicateParentState = "true" : Textuses = "12p /" & Lt; / FrameLayout & gt;   

    With XML layouts for overall control, I have created a Java implementation as described in the Android documentation, which looks something like this:

      Public class custombutton framelayout {extends public customboot (context reference, attribatate etter) {super (references, ethers); Layout Influencer LayoutEflator = (Layout Inflator) Reference. Gate System System (References LAOUT_INFLATER_SERVICE); LayoutInflatInFallet (R.Latout.control_helelbutton, this, true); }}   

    If I understand correctly, when this control is used, the construction hierarchy will be used (indicates the bracket where the scene is defined):

      FrameLayout Java) - & gt; FrameLayout (XML) - & gt; 2x TextView (XML)   

    I want to be able to toggle whether my custom button has been enabled or not in context of the button and by setting the capable asset, such as: Custom Button Button = (Custom Button) FindVBIID (R.B.ton); button.setEnabled (false);

    Although this does not work, because the framelays defined in XML are not the heir to the properties of their parents, and such buttons are displayed as enabled.

    I have tried to add duplicatepointstate = true for the FrameLayout defined in XML, but in that case my style attribute has been overwritten / inherited and control no longer looks like a button.

    I have also tried to use the merge tag as a style program, but as far as I can tell it is not possible to set the view as a program.

    My workaround has been made to overwrite the setEnabled () method so far on custom buttons such as:

      Enable Public Zero Set (Boolean enabled) {super. SetEnabled (enabled); findViewById (R.id.button_rootLayout) .setEnabled (enabled); }   

    This works but I have to do this for every property that I want to modify programmatically, and I have similar problems in registering onclick listener.

    Is anyone better?

    How about:

      enabled public zeros set (Boolean Enabled) {Super.Sent enabled (enabled); setClickable (enabled); }   

    This is what I am doing

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -