我正在开发一个表单,并使用jQuery UI Autocomplete.当用户选择一个选项时,我希望选择弹出一个附加到父<p>标签的范围.然后我希望字段清除而不是填充选择.
我的跨度看起来很好,但是我无法清除这个领域.
如何取消jQuery UI Autocomplete的默认选择操作?
这是我的代码:
var availableTags = ["cheese", "milk", "dairy", "meat", "vegetables", "fruit", "grains"];
$("[id^=item-tag-]").autocomplete({
source: availableTags,
select: function(){
var newTag = $(this).val();
$(this).val("");
$(this).parent().append("<span>" + newTag + "<a href=\"#\">[x]</a> </span>");
}
});
Run Code Online (Sandbox Code Playgroud)
简单地做$(this).val("");就行不通.令人抓狂的是,如果忽略自动完成功能,几乎所有功能都能正常工作,只需在用户输入逗号时执行操作:
$('[id^=item-tag-]').keyup(function(e) {
if(e.keyCode == 188) {
var newTag = $(this).val().slice(0,-1);
$(this).val('');
$(this).parent().append("<span>" + newTag + "<a href=\"#\">[x]</a> </span>");
}
});
Run Code Online (Sandbox Code Playgroud)
真正的最终结果是使自动完成功能可以进行多项选择.如果有人对此有任何建议,欢迎他们.
我正在使用适配器在列表视图中显示图像和一些文本.图像从Web中提取,然后在本地缓存并显示.图像已经很小(60px方形),我知道它们的大小,所以我使用了这里的建议,建议我使用setImageURI而不是解码位图.
完成这项工作的课程是Fedor的ImageLoader的修改版本
代码将一个可绘制的存根附加到ImageView,直到从Web下载所需的图像,然后从SD卡加载缓存的文件.在Android 2.2中,这很好用.这很快,我没有OOM崩溃.但是在2.1上,我收到以下错误:
09-15 11:04:52.993: INFO/System.out(240): resolveUri failed on bad bitmap uri: file:///sdcard/android/data/com.example.myapp/cache/4164137
Run Code Online (Sandbox Code Playgroud)
ImageLoader类如下:
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy …Run Code Online (Sandbox Code Playgroud) 因此,我的应用程序会根据用户的要求从在线来源下载图像.通过活动中的按钮,用户可以选择隐藏或显示图库中的图像.这很容易,我只需根据需要添加或删除.nomedia文件.但是,我希望每次都重新扫描媒体,以便更改是即时的,并且不需要进一步的用户交互.
下载完每个图像后,我将使用http://www.mail-archive.com/android-developers@googlegroups.com/msg24164.html上的方法将特定图像扫描到库中.这适用于一个图像,但是当添加.nomedia文件时,我真的需要能够扫描整个目录.
我曾考虑在目录中的每个图像上调用MediaScannerNotifier,但这看起来很笨拙和懒惰.
建议吗?