我实现了懒人加载图像ListView.我使用a AsyncTask从Internet下载图像并将其绑定到UIThread中的ImageView.
它的工作原理除外,当我ListView快速滚动变化时,下载的图像有时被绑定到列表中的错误项目中.
我想这个问题是从重用convertView的BaseAdapter.有什么想法可以解决吗?
非常感谢.
编辑:我发布的答案如下:
public void setBitmap(int position, Bitmap image) {
View itemView = mListView.getChildAt(position - mListView.getFirstVisiblePosition());
if (itemView != null) {
ImageView itemImageView = (ImageView) itemView.findViewById(R.id.item_imageview);
itemImageView.setImageBitmap(image);
}
}
Run Code Online (Sandbox Code Playgroud) 11-24 23:19:18.434: ERROR/AndroidRuntime(12660): Uncaught handler: thread main exiting due to uncaught exception
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@4384c218
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.graphics.Canvas.throwIfRecycled(Canvas.java:955)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.graphics.Canvas.drawBitmap(Canvas.java:1044)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:291)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.widget.ImageView.onDraw(ImageView.java:908)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.View.draw(View.java:6283)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.ViewGroup.drawChild(ViewGroup.java:1581)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1311)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.ViewGroup.drawChild(ViewGroup.java:1579)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1311)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.View.draw(View.java:6286)
11-24 23:19:18.684: ERROR/AndroidRuntime(12660): at android.view.ViewGroup.drawChild(ViewGroup.java:1581)
11-24 …Run Code Online (Sandbox Code Playgroud) 我添加了intent-filter.当我点击图库中的"分享"时,它将启动我的活动.
<intent-filter>
<action
android:name="android.intent.action.SEND" />
<category
android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="image/*" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
但我不知道如何从当前意图中获取正确的数据.有帮助吗?
编辑:抱歉,在问题中缺少"图片"
如果我使用默认组指示器(不设置新组),我如何知道组视图布局的填充宽度?
因此可以让我的布局不会与群组指标重叠.
那可能吗?因为我找不到getGroupIndicator的方法.或者我必须设置一个我知道它的大小的新的.
如果它必须用AIDL实现?请提供一个例子,谢谢.
编辑:有几个解决方案,有谁知道哪个更好?
我想在html中找到以下标记.
<a href="http://www.google.com/AAA" class="link">AAA</a>
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用像[href ^ = http://www.google.com/]或[class = link]这样的选择器.但是我如何结合这两个条件呢?
或者有更好的方法吗?像正则表达式?如何?谢谢!
我想设置一个TextView与SpannableString这从下面的方法:
Html.fromHtml(String source, Html.ImageGetter imageGetter,
Html.TagHandler tagHandler)
Run Code Online (Sandbox Code Playgroud)
但是ImageGetter这里需要覆盖以下方法:
public abstract Drawable getDrawable(String source)
Run Code Online (Sandbox Code Playgroud)
因为我需要从互联网上获取可绘制的内容,所以我必须异步进行,而不是.
如何使它工作?谢谢.
如何重叠RecyclerView中的项目?像堆叠卡一样.
提前致谢.
我应该如何构建实体以实现此发布请求?
POST https://picasaweb.google.com/data/feed/api/user/userID/albumid/albumID/photoid/photoID
<entry xmlns='http://www.w3.org/2005/Atom'>
<content>great photo!</content>
<category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/photos/2007#comment"/>
</entry>
Run Code Online (Sandbox Code Playgroud)
它来自:http: //code.google.com/intl/zh-TW/apis/picasaweb/docs/2.0/developers_guide_protocol.html#AddComments
有人可以提供示例或任何提示吗?非常感谢.
更新:我在这里添加了我的代码:
List<Header> headers = new ArrayList<Header>();
headers.add(new BasicHeader("GData-Version", "2"));
headers.add(new BasicHeader("Authorization", "GoogleLogin auth=" + mAuthToken));
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(OutputStream ostream) throws IOException {
Writer writer = new OutputStreamWriter(ostream, "UTF-8");
writer.write("\r\n");
writer.write("<entry xmlns='http://www.w3.org/2005/Atom'>");
writer.write("<content>" + comment + "</content>");
writer.write("<category scheme=\"http://schemas.google.com/g/2005#kind\"\r\n");
writer.write("term=\"http://schemas.google.com/photos/2007#comment\"/>");
writer.write("</entry>\r\n");
writer.flush();
}
});
Run Code Online (Sandbox Code Playgroud)
仍然没有运气.任何的想法?