How do I set up a constructor in a custom TextView to be able to pass text from a fragment?
In other words, I\'m confused how to send text from my fragment (Fragment1) t
You are extending a TextView
anyway. As A--C mentioned, you can use getText()
, as well as setText()
to get and set the text.
In your context, I am not sure if it is a good idea to use TextView
to implement your custom view/widget. View might be a better starting point, as TextView
carries all kind of stuff around for formatting, icon/drawable display, click/button logic etc.
You need to define the standard constructors if you want to be able to have the system instantiate/inflate your components from an XML layout. Then you can use standard getters/setters for your data, same way as all other controls do it.
If you instantiate your widget/view yourself (in your code), you are free to define whatever constructors you want to (I believe).