0

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 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?

compuguru
  • 1,035
  • 1
  • 10
  • 20
  • I guess you would be better off constructing a custom ListView Adapter than going through this hassle. Check www.androidguys.com/tag/android-listview/ on how to create a ListView adapter in the Fancy ListView section written by Mark Murphy – chaitanya Apr 27 '11 at 18:52
  • Using a ListView adapter was my first approach, but I need the actual rows to be clickable, along with allowing the user to enter a number in the EditText. But the clicking does not work as described [here](http://stackoverflow.com/questions/2098558/listview-with-clickable-editable-widget). There is a workaround [here](http://www.androidsnippets.com/clickable-listview-items) but it seems long so I was looking at taking a different approach. – compuguru Apr 27 '11 at 20:27

1 Answers1

0

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

Spidy
  • 39,723
  • 15
  • 65
  • 83