1

I want to know if it is possible to make a textview load on the screen when a button is pressed...

I do not want to make the textview invisible, then visible when the button is pressed, I want it to actually (dynamically) appear on the screen.

Any help?

user802609
  • 799
  • 6
  • 19
  • 34
  • 1
    Do you have any code that you are working off of? If so, please post it in your question. – Phil Aug 04 '11 at 02:55
  • 1
    similar question [here](http://stackoverflow.com/questions/6216547/android-dynamically-add-views-into-view) about adding view dynamiclaly – Patrick Kafka Aug 04 '11 at 03:03
  • Read my [post][1], this will solve your problem. [1]: http://stackoverflow.com/questions/6930604/android-add-textview-to-layout-when-button-is-pressed/6932540#6932540 – kameny Aug 04 '11 at 06:52

1 Answers1

1

You have to dynamically add view in a parent view for that you have to create a view

for example You have a parent view name layParent and you want to add textview inside layParent for first make a textview using code like this

TextView tv = new TextView(context)
tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tv.setText("textview");
layParent.addView(tv);

write this code in button click event so that you can add text-view as many as you click on button

for more information see this question

Android - Dynamically Add Views into View

Community
  • 1
  • 1
Dharmendra
  • 33,296
  • 22
  • 86
  • 129