Tuesday, 15 June 2010

android - Supplying text from fragment to custom TextView -



android - Supplying text from fragment to custom TextView -

how set constructor in custom textview able pass text fragment?

in other words, i'm confused how send text fragment (fragment1) custom view (view1):

public class view1 extends textview { //constructors: public view1(context context, attributeset ats, int ds) { super(context, ats, ds); init(); } public view1(context context) { super(context); init(); } public view1(context context, attributeset attrs) { super(context, attrs); init(); } ... canvas.drawtext(mystring, margin1, margin2, paint); //mystring fragment1 .... }

i asked similar question here, didn't much help. illustration code go long way towards clearing confusion. in advance!

you extending textview anyway. a--c mentioned, can utilize gettext(), settext() , set text.

in context, not sure if thought utilize textview implement custom view/widget. view might improve starting point, textview carries kind of stuff around formatting, icon/drawable display, click/button logic etc.

you need define standard constructors if want able have scheme instantiate/inflate components xml layout. can utilize standard getters/setters data, same way other controls it.

if instantiate widget/view (in code), free define whatever constructors want (i believe).

android android-fragments android-textview

No comments:

Post a Comment