我有一个惯例<代码>ListView和改编者。 我可以删除我的习惯名单上所列清单中的项目,但我可以删除<代码>ListView。 当我试图打电话adapter.remove(position)
时,编辑们说,“将一种方法“remove(int status)”
。 我不知道,当我把这种方法引入适应者时,我应该做些什么。 法典:
www.un.org/spanish/ecosoc
lv = (ListView) findViewById(R.id.list);
LayoutInflater mLInflater = getLayoutInflater();
final ListViewAdapter adapter = new ListViewAdapter(
getApplicationContext(), kimdenlist, konulist,
mLInflater);
lv.setAdapter(adapter);
www.un.org/spanish/ecosoc 清单:
public class ListViewAdapter extends BaseAdapter {
static HashMap<Integer, Boolean> cartItems = new HashMap<Integer, Boolean>();
Context mContext;
ArrayList<String> kimdenlist; // to load images
ArrayList<String> konulist; // for data
LayoutInflater mLayoutInflater;
public ListViewAdapter(Context context, ArrayList<String> kimdenlist, ArrayList<String> konulist,
LayoutInflater layoutInflater) {
mContext = context;
this.kimdenlist = kimdenlist;
this.konulist = konulist;
mLayoutInflater = layoutInflater;
}
@Override
public int getCount()
{
return kimdenlist.size(); // images array length
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int arg0) {
return 0;
}
int count = 0;
// customized Listview
@Override
public View getView(int position, View arg1, ViewGroup arg2) {
View v;
final int pos = position;
v = mLayoutInflater.inflate(R.layout.listust, null);
TextView kimden = (TextView) v.findViewById(R.id.textvKimden);
kimden.setText(kimdenlist.get(position));
TextView konu = (TextView) v.findViewById(R.id.textvKonu);
konu.setText(konulist.get(position));
CheckBox ch = (CheckBox) v.findViewById(R.id.chk);
try {
if (count != 0) {
boolean b = cartItems.get(pos);
if (b == false)
ch.setChecked(false);
else
ch.setChecked(true);
}
} catch (NullPointerException e) {
}
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
cartItems.put(pos, arg1);
count++;
}
});
return v;
}
public static HashMap<Integer, Boolean> getcartItems() {
return cartItems;
}
}
www.un.org/spanish/ecosoc 当我点击“delete_Button”时: 我只能从名单上删除:。
konulist.remove(konulist.get(position));;
kimdenlist.remove(kimdenlist.get(position));