Reputation: 16354
Here is a screenshot of my application where the details of a particular entry are displayed on the right hand side when any child is clicked in the ExpandableListView.
The user can edit the details of each child on the right hand side and use the BackButton to save the details.
Now, what I want to achieve is that when the user clicks on another child, the edits made on the previous entry should also be saved.
I am not attaching my code, as the code is really very long and complex. To simplify matters let's say that I store all the entries in a 2-D array named "SlotList" and whenever any child is clicked I copy the details of that child in an Object (named CurrentSlot) and perform the edits on the data members of CurrentSlot. Now, when the user presses the BackButton, I save the details of the CurrentSlot via SaveCurrentSlot(Slot object).
What I want to do is call SaveCurrentSlot(Slot obj) when the user clicks on another child in the ExpandableList.
Any suggestions/ hints on how I should do it ?
Thanks in advance. :)
Upvotes: 1
Views: 531
Reputation: 21191
I think its better to use onChildClick method for your requirement.
>>Basing on the child click position you can set data to layout right.
use this method
public boolean onChildClick( ExpandableListView parent, View v, int groupPosition,int childPosition,long id) {
System.out.println("Inside onChildClick at groupPosition = " + groupPosition +" Child clicked at position " + childPosition);
//ur code here
return true;
}
For more details of child click in expandable list view visit this
Upvotes: 2