我使用下面的链接给出代码如何从列表视图中删除项目
http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
请帮助我如何从列表视图中删除一个项目
我使用下面的链接给出代码如何从列表视图中删除项目
http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
请帮助我如何从列表视图中删除一个项目
取下适配器和呼叫项目notifyDataSetChanged()。它应该刷新你的列表视图的内容。
可否请您发布代码 – 2011-03-11 06:30:28
明白了.....谢谢 – 2011-03-11 06:40:47
public View getView(int position, View convertView, ViewGroup parent) {
final TableRow row = this.rows.get(position);
ImageButton imgButton = (ImageButton) itemView.findViewById(R.id.icon);
imgButton.setTag(row);
@Override
public void onClick(View v) {
ImageButton button = (ImageButton) v;
TableRow row = (TableRow) button.getTag();
tableRowAdapter.deleteRow(row);
tableRowAdapter.notifyDataSetChanged();
}
只是一个想法不完整的代码。 – 2011-03-11 10:08:44
只需在您的'ArrayList'的特定位置移除该项目并调用方法'adapter.notifyDataSetChanged()'。 – 2011-03-11 06:23:21