alertDialogBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
try {
expenses = editText.getText().toString();
int a = (int)getGroupId(groupPosition);
Log.e("group id",String.valueOf(a));
obj.prepareListData(expenses,(int) getGroupId(groupPosition));
} catch (Exception e) {
Log.e("123", e.toString());
}
}
});
public void prepareListData(String s, int position) {
List<String> expenses = new ArrayList<String>();
expenses.add(s);
listDataChild.put(listDataHeader.get(position), expenses);
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
}
在这里,我想将不同的费用添加到不同的组(标题(中,但费用被覆盖到前一个到标题中。
如何将不同的多个值添加到不同的组(标题(中? 请指导我。
您不应该在每次更改数据时都实例化 ExpandableListAdapter。
您应该只修改数据列表,然后调用 listAdapter:
adapter.notifyDataSetChanged();
这将自动应用数据更改!