New to Android: Dynamically changing views
Posted
by Josiah Kiehl
on Stack Overflow
See other posts from Stack Overflow
or by Josiah Kiehl
Published on 2010-06-18T03:03:23Z
Indexed on
2010/06/18
3:13 UTC
Read the original article
Hit count: 315
I'm trying to learn how to build apps for Android.
The first simple app, which will become a component of a bigger app I hope to build, is to have a button on the screen where, when tapped, it adds something new to the view.
For instance:
Imagine a layout that only has a button:
[Create!]
When that button, the view gets a new row added to it:
[Create!]
A Something!
Upon subsequent presses, more rows are added
[Create!]
A Something!
A Something!
And so on.
I've made a LinearLayout and placed the button in it, and have attached a click listener to it. That all works great. What I can't figure out is how to get a handle on the LinearLayout in the onClick function with which I'll addView() the new TextView that says "A Something!"
Am I on the right track? What basic thing am I missing? Thanks!
© Stack Overflow or respective owner