WEB开发网
开发学院手机开发Android 开发 通过改写ArrayAdapter 用AutoCompleteTextView 实... 阅读

通过改写ArrayAdapter 用AutoCompleteTextView 实现汉字和拼音双向关联

 2010-07-15 20:43:00 来源:WEB开发网   
核心提示:* @param object The object to insert into the array.* @param index The index at which the object must be inserted.*/public void insert(T object, int index) {if

* @param object The object to insert into the array.

* @param index The index at which the object must be inserted.

*/

public void insert(T object, int index) {

if (mOriginalValues != null) {

synchronized (mLock) {

mOriginalValues.add(index, object);

if (mNotifyOnChange) notifyDataSetChanged();

}

} else {

mObjects.add(index, object);

if (mNotifyOnChange) notifyDataSetChanged();

}

}

/**

* Removes the specified object from the array.

*

* @param object The object to remove.

*/

public void remove(T object) {

if (mOriginalValues != null) {

synchronized (mLock) {

mOriginalValues.remove(object);

}

} else {

mObjects.remove(object);

}

if (mNotifyOnChange) notifyDataSetChanged();

}

/**

* Remove all elements from the list.

*/

public void clear() {

if (mOriginalValues != null) {

synchronized (mLock) {

mOriginalValues.clear();

}

} else {

mObjects.clear();

}

if (mNotifyOnChange) notifyDataSetChanged();

}

/**

* Sorts the content of this adapter using the specified comparator.

*

* @param comparator The comparator used to sort the objects contained

* in this adapter.

*/

public void sort(Comparator comparator) {

Collections.sort(mObjects, comparator);

if (mNotifyOnChange) notifyDataSetChanged();

}

/**

* {@inheritDoc}

*/

@Override

public void notifyDataSetChanged() {

super.notifyDataSetChanged();

mNotifyOnChange = true;

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:通过 改写 ArrayAdapter

编辑录入:coldstar [复制链接] [打 印]
赞助商链接