public void remove(T object) { synchronized (mLock) { if (mOriginalValues != null) { mOriginalValues.remove(object); } else { mObjects.remove(object); } } if (mNotifyOnChange) notifyDataSetChanged();//通知观察者 }
mListView = (ListView) findViewById(R.id.lv); String[] data = { "aaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbb", "aaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbb", "aaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbb", "aaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbb", }; final List<String> d = new ArrayList<String>(Arrays.asList(data)); mAdapter = new ArrayAdapter<String>(this, R.layout.item, R.id.tv,d); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(int postion) { mAdapter.remove(mAdapter.getItem(postion)); } });
public ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) { init(context, resource, textViewResourceId, Arrays.asList(objects)); }
List<String> d = new ArrayList<String>(Arrays.asList(data));