我找不到简单易用的解决方案来检测文本字段中的更改。我不想使用,(keypress)因为用户有时会将值粘贴到字段中。(onchange)仅在用户模糊场时才起作用。我想立即发现变化。
什么是最简单的angular js $ watch等价物?
我有一个包含多个项目的ListView,列表中的每个项目都应该有一个与之关联的图像.我创建了一个数组适配器来保存每个列表项,并具有我想要加载的图像的URL.
我试图使用Web请求异步加载图像并让它设置图像并在加载后在视图中更新它,但视图应立即使用默认图像进行渲染.
这是我用来尝试加载图像的方法
private async Task<Bitmap> GetImageBitmapFromUrl(string url, ImageView imageView)
{
Bitmap imageBitmap = null;
try
{
var uri = new Uri(url);
var response = httpClient.GetAsync(uri).Result;
if (response.IsSuccessStatusCode)
{
var imageBytes = await response.Content.ReadAsByteArrayAsync();
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
imageView.SetImageBitmap(imageBitmap);
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
return imageBitmap;
}
Run Code Online (Sandbox Code Playgroud)
我正在初始化我的HttpClient,如下所示:
httpClient = new HttpClient();
httpClient.Timeout = new TimeSpan(0, 0, 10);
httpClient.MaxResponseContentBufferSize = 256000;
Run Code Online (Sandbox Code Playgroud)
以下是我调用GetImageFromUrl方法的方法
ImageView myImage = convertView.FindViewById<ImageView>(Resource.Id.AsyncImageView) …Run Code Online (Sandbox Code Playgroud)