1

Is there any way to find the view that represents a specific row in a listview.

When the user clicks on a row in my listview I expand it to show more details (using the ExpandAnimation class). Thing is that when I click on another row I want the previously opened row to close. So, I need to be able to get at the view (I have the row number within the dataset).

If the row is not on the screen at present then it is not a problem because it will be shrunk down when getView is called.

So, is there any way to get the view by index in list adapter.

theblitz
  • 6,683
  • 16
  • 60
  • 114
  • 2
    your getview position parameter is the index. – Raghunandan Jun 16 '13 at 13:23
  • that's only good when I am building the listview. At that point I get the index and return a view with the data included. I am talking after it is displayed to the user. I need to get from the row id back to the view I created. – theblitz Jun 16 '13 at 13:42
  • http://stackoverflow.com/questions/7645880/list-view-with-on-item-click-listener-android. listview on item click listener the third parameter is the position ie index. is this what your looking for? – Raghunandan Jun 16 '13 at 13:50
  • Nope. I am not looking for the one I just clicked on. I need to get to a different one based on its position in the list adapter. I know that it may not even be on the screen in which case I would expect to get null. – theblitz Jun 16 '13 at 14:44
  • Why don't you just hold a reference to the view that was previously clicked and then collapse this view, when another view is clicked. After you change the variable holding the last clicked view to the new view. – Darwind Jun 16 '13 at 18:51
  • I don't want to do that because if it is then scrolled out of the top of the list Android will not be able to re-cycle it. – theblitz Jun 17 '13 at 05:25
  • have you found a solution @theblitz ? – Mikel Dec 04 '13 at 11:52

0 Answers0