First, take an example of simply viewing a list, not a drop-down list. ListView is a container containing a bunch of items.
These items have child views, which are made up of individual items that make up a row in a ListView. those. various text elements, etc.
The adapter's GetView () works with the data set and then creates the items in the list. Therefore, if you change the dataset that is used to create the adapter and call notifyDatasetChanged (), it will update the list view.
Now, in your case, you can use ArrayList to represent objects of type "NORTH". Therefore, if you store the count value in this object, then updating the counter will be simple. Just access the data in the list using groupPosition and update it. And call notifyDatasetChanged.
Say you used mList, which is an ArrayList of type Object, to create an adapter
// ArrayList<Object> mList; // You created mAdapter from this mList // now mList is data set for this adapter
So in getChildView () you write:
@Override public void onClick(View v) { boolean isChecked = ((CheckBox) v).isChecked(); ApplicationController.getEventBus().post(((OutletData) getChild(groupPosition, childPosition)).getOutletID()); if (isChecked) {
Now the only limitation of this approach is that the account must be part of the object. Therefore, if you first initialize the counter from some other, but not from the object itself, I recommend that you store the count in the object itself and initialize the value of textView.
So in getGroupView ()
groupViewHolder.GroupCount.setText(""+((OutletListData) getGroup(groupPosition)).getCount());
source share