我目前正在将数据库管理器移植到android,由于性能原因,我只想更新已修改的属性.我试图用addTextChangedListener来做这个,以便将修改后的entrys添加到List,但我的程序从不进入任何方法.
EditText Et = (EditText) Editors.get(Prop.Name);
Et.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
if(Prop.GetType() == Property.PROPTYPE.num) {
float f = Float.parseFloat(s.toString());
Prop.FromString(f);
}
else {
Prop.FromString(s.toString());
}
propertiesToUpdate.add(Prop);
});
Et.setText(Prop.ToString());
Run Code Online (Sandbox Code Playgroud) 我已经在我的ListView中实现了一个搜索栏,到目前为止它正常工作,除了适配器表现得很奇怪.每当我调用其清除功能时,我的列表视图仍会显示"旧"内容.
public abstract class MYLISTITEM extends BaseAdapter {
private Context activity;
private List<String> data;
private static LayoutInflater inflater=null;
private int ItemIcon;
private boolean moreVis;
public MYISTITEM(Context a, int IconID,boolean vis) {
activity = a;
data = new ArrayList<String>();
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ItemIcon = IconID;
moreVis = vis;
}
public void add(String object)
{
data.add(object);
notifyDataSetChanged();
}
public void replace(int index,String object)
{
data.set(index, object);
notifyDataSetChanged();
}
public void clear()
{
data.clear();
notifyDataSetChanged();
}
public void remove(Object object)
{
data.remove(object);
notifyDataSetChanged(); …Run Code Online (Sandbox Code Playgroud) android ×2