I need to have an edit option in tableLayout just like in iphone UITableView. When edit button is clicked a Delete button should appear in each row of tableLayout. What I just did was I created a Delete button in each row at runtime and made it hide. And when Edit button is clicked, Delete button gets visible. But I don’t think it seems to be a good practice.
Is there an inbuilt functionality for this? What is the best practice I should follow?
Thanks and regards
You can always make a seperate xml file containing only a delete button and then inflate it into all the rows when the edit button is clicked.That way you dont have to hide all those delete buttons and can add them only if needed…
Create a new xml file under res->layout and add only this to it
Then just inflate it into your row.
For more info this is a good tutorial to understand inflation- http://blog.jayway.com/2009/03/26/layout-resources-in-android/
Good luck! 🙂