开发者

How to Store Data for a View

I'm working on my first Android App and am still trying to learn how the structure for everything goes. At the moment, I have a "view" called "row". Row has some TextViews and an EditText view in it that are filled when the view is created. For the main program, I use a ScrollView and add the Rows to it. A ListView would be more ideal, but 开发者_JAVA技巧the EditText messes things up.

At this point, I can create multiple Rows and add them to the ScrollView (Actually I add them to the LinearLayout inside the ScrollView). But how do I access the values each one contains? I believe they all have the same ID (row). My first thought was to create an array of "item" objects that hold the data and somehow bind each one to a view, but I'm not sure how to do that. Are there any suggestions, tutorials, or samples that I should look at?


Two solutions for this.

First you could use a ListView and make your own custom Adapter. The adapter is what takes care of displaying the items and you could add an EditText view in there.

Second, for your current setup. I'm not sure what your code looks like but if you call findViewById on the Row View you'll get the control for the id in that row, not the other rows. So even though items have the same id, you can filter them by calling the find specifically on the parent row view

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜