Thursday, 15 April 2010

android - How to add multiple TextViews programmatically to a RelativeLayout -



android - How to add multiple TextViews programmatically to a RelativeLayout -

how 1 programmatically, via 1 button click @ time, add together multiple textviews existing relativelayout without textviews overlapping onto 1 another.

i trying - next code exists within oncreate() method:

textview textviewtoseefirst = (textview) findviewbyid(r.id.textview1); relativelayout rlayout1 = (relativelayout) findviewbyid(r.id.relativelayout1); button button1 = (button) findviewbyid(r.id.button1); button1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { relativelayout.layoutparams lparams = new relativelayout.layoutparams (layoutparams.match_parent, layoutparams.wrap_content); textview newtextview = new textview(theactivityyouareusingactivity.this); newtextview.settext("text want"); rlayout1.addview(newtextview, lparams); }

the textviews beingness added relativelayout, on top of 1 another, how 1 prepare this?

why dont add together text views in xml file (as much want) before running app. set visibilities textviews dont want show "gone" , in button click listener maintain changing visibility of textview "view.visible" . if want new textview appear each time press button set counter button , each time counter increments alter want textview's visibility view.visible. if understood saying able create code on own.

android relativelayout overlapping

No comments:

Post a Comment