如何在Android中通过XML解析在Gallery上设置图像?

发布于 2024-12-27 16:41:54 字数 84 浏览 2 评论 0原文

我可以通过 XML 解析在 ListVew 上设置图像,但无法在 Gallery 上设置图像。请让我知道如何做到这一点,任何教程或示例的链接都会有所帮助。

I can set Image on ListVew through XML parse but I can't set image on Gallery. Please let me know how to do that and any links to tutorials or sample could would help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南汐寒笙箫 2025-01-03 16:41:54

这个问题没有具体的答案。你必须使用很多东西。您只需搜索图库视图和惰性适配器...

This question has not a specific answer. You have to use many things. You just search on Gallery view and Lazy adapter...

所谓喜欢 2025-01-03 16:41:54

通过使用XML解析,解析所有图像url。获取所有图像网址后,您可以使用 ListView 中图像的延迟加载。在 LazyLoading 代码中,他们在布局中使用了 ListView,因此图像和相应的文本显示为列表项,您可以将该 ListView 更改为 Gallery,如下所示:

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Gallery android:id="@+id/gallery" android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Clear Cache"/>
    </LinearLayout>

我认为这会给您带来所需的结果。

By using the XML parsing, parse all the image url's. After getting all the image url's you can load the images using Lazy load of images in ListView. On the LazyLoading code they have used a ListView in the layout so the images and the corresponding text are shown as list items, you can change that ListView to a Gallery something like this:

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Gallery android:id="@+id/gallery" android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Clear Cache"/>
    </LinearLayout>

I think this will get you the desired result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文