You basically need a context to create and possibly a layout to add
TextView tv = new TextView(mContext);//context can be an activity or u can
use getBaseContext();
tv.setLayoutParams(new LayoutParams(50,60));//set some height and width and
it can be wrap_content or fill_parent
tv.setText("hello Android");
layout.add(tv);//this can be any layout if you have linearlayout in ur xml
file then
//find it by LinearLayout
layout=(LinearLayout)findViewById(R.id.main);
You can do this in onclick event or a menu event upto you.
This should work in general , you can play around with it.
On Wed, May 5, 2010 at 10:26 AM, John Gaby <[email protected]> wrote:
> I am new to Android development. I would like to be able to add child
> views (e.g. buttons, text, etc.) to my main view at runtime, and to be
> able to position and size those views dynamically. I cannot figure
> out exactly how to do that. Can anyone point me in the right
> direction?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en