如何刷新从BaseExpandableListAdapter删除一行之后的ListView行? [英] How to refresh ListView row after delete row from BaseExpandableListAdapter?
问题描述
在我的应用程序我使用BaseExpandableListAdapter显示我的数据库。我在getChildView,当我点击它当前行被删除,创建一个按钮。我的问题是,在ListView上MainActivity.class,而不是在BaseExpandableListAdapter.class更新。我怎样才能刷新数据后,在不同的类被改变,而清爽的实时性。
In my app i'm using BaseExpandableListAdapter to show my database. i created a button in the "getChildView" and when i click it the current row is deleted. my problem is that the listView updating on the MainActivity.class and not at BaseExpandableListAdapter.class . how can i refresh the data after was changed in a different class and refreshing in real time.
MainActivity.class我得到从数据库中的数据的ArrayList
MainActivity.class i get the data from Db in ArrayList:
hand = new DbHandler(getActivity());
fullList = new HashMap<ArrayList<ClockModel>, ArrayList<ClockModel>>();
ArrayList<ClockModel> temp = new ArrayList<ClockModel>();
child = new ArrayList<ClockModel>();
child = hand.getDay(workName);
for (int i = 0; i < child.size(); i++) {
ClockModel m1 = new ClockModel(
child.get(i).getId(),
child.get(i).getWorkName(),
child.get(i).getDateDay(),
child.get(i).getDateMonth(),
child.get(i).getDateYear()
temp.add(m1);
fullList.put(child, child);
}
和上BaseExpandableListAdapter我有一个按钮,删除该spacific行:
and on BaseExpandableListAdapter i have a button that delete the spacific row:
btnRemove = (ImageButton) convertView.findViewById(R.id.row_btnRemove);
btnRemove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DbHandler hand = new DbHandler(context);
int currendId = fullList.get(child).get(groupPosition).getId();
hand.deleteDay(currendId);
Toast.makeText(context, "Del : "+currendId, 2000).show();
}
});
感谢你..:)
推荐答案
删除行使用通知适配器之后
After deleting row notify adapter using
adapter.notifyDataSetChanged();
这篇关于如何刷新从BaseExpandableListAdapter删除一行之后的ListView行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!