Android extending views, specifically RadioButton
I'm trying to implement a RadioButton that has a TextView on the top right part of it, like so:
The Textview will hold a number, once I've clicked something in the app.
I understand that I will have to extend RadioButton and add a TextView in there somehow, but I don't really understand how. I'd like to be able to configure all aspects of the button in xml (background of textview, if textview is visible and so on).
How do I go about this? Where do I st开发者_运维百科art?
1) You need to make sure it eventually will act and behave like a radio button, what ever you do make sure your radioButton can be added to RadioGroup.
2) This tutorial will give you some tips on creating custom components http://hugman.posterous.com/parameterizing-a-custom-components-to-promote and http://developer.android.com/guide/topics/ui/custom-components.html
3) If you want to edit the properties in XML editor, you need to create a constructor for your custom button that accepts XML attributes
4) If you simply want to do this inline, in a Layout add a radioButton and a textBox where ever you want. Pass all the touch events on the layout to the radio button sp that it toggles on touch and add the Layout to your RadioGroup(will need a little tweaking).
精彩评论