【问题标题】:QuiltView Gallery with Pull to Refresh in Android?QuiltView Gallery 在 Android 中具有拉取刷新功能?
【发布时间】:2015-12-24 17:38:40
【问题描述】:

我正在使用 QuiltViewLibrary 在 Android 中开发一个社交网络应用程序来制作 QuiltView 图像库。

在同一个应用程序中,我为 GridView 使用了 HANDMARKS Pull to Refresh 库

两者都工作正常。现在我必须为组合任务实现这两个库,即 QuiltView GALLERY 中的 PULL TO REFRESH。

我遇到的问题是将两个完全不同的 LIBRARIES 的 XML 结合起来。

带有简单网格视图的 PullToRefresh 的 XML:

<!-- The PullToRefreshGridView replaces a standard GridView widget. -->
    <com.handmark.pulltorefresh.library.PullToRefreshGridView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/pull_refresh_grid"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:numColumns="auto_fit"
        android:verticalSpacing="1dp"
        android:horizontalSpacing="1dp"
        android:columnWidth="100dp"
        android:stretchMode="columnWidth"
        android:gravity="fill"
        ptr:ptrMode="both"
        ptr:ptrDrawable="@drawable/ic_launcher" />

</LinearLayout>

QuiltView Gallery 的 XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:quilt="http://schemas.android.com/apk/res/com.tv.photos"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" >

    <com.tv.photos.QuiltView
        android:id="@+id/quilt"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dip" >
    </com.tv.photos.QuiltView>

</FrameLayout>

如果有人可以给我一些建议,请告诉我。

【问题讨论】:

    标签: android pull-to-refresh quiltview


    【解决方案1】:

    这很简单:

    • Chris Banes 的 pulltorfresh 库支持 ScrollView
    • QuiltView 库只是 GridLayout 的扩展(不是 GridView 或任何其他适配器类)

    QuiltView 的实例放在PullToRefreshScrollView 的实例中。例如javaxml

    不应该比这更复杂:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <com.handmark.pulltorefresh.library.PullToRefreshScrollView
            xmlns:ptr="http://schemas.android.com/apk/res-auto"
            android:id="@+id/pull_refresh_scrollview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
    
            <com.tv.photos.QuiltView
                android:id="@+id/quilt"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="5dip" />
    
        </com.handmark.pulltorefresh.library.PullToRefreshScrollView>
    
    </LinearLayout>
    

    【讨论】:

      【解决方案2】:

      您可以继续使用 handmark 的 pulltorefresh 库并创建一个 pulltorefresh 视图,该视图可与其中的 quiltview 一起使用。 由于 QuiltView 扩展了 FrameLayout,所以不能直接在 handmark 的 pull 刷新中使用它,但是你有 3 个选项摆在你面前:

      1.通过扩展 PullToRefreshBase 类创建新的 PullToRefreshQuiltView 类。

      只需创建一个扩展 PullToRefreshBase 的类 您可以查看 PullToRefreshWebView 类以了解如何执行此操作。

      2。在 QuiltView 的设置函数中使用滚动视图

      See line 50 of this link 您可以将 setup 函数中的滚动视图更改为 pullToRefreshScrollView,或者将此滚动视图添加到 ptr 视图。

      3.在 Handmark 的 PullToRefresh 或 android SwipeRefreshLayout 中使用 RecyclerView 和 GridLayoutManager

      另一种选择是在 handmark 的 pulltorefresh 或 android 的 SwipeRefreshLayout 中使用带有 GridLayoutManager 的 RecyclerView(类似于 GridLayoutManager Span Size RecycleView 的东西)。

      有关 SwipeRefreshLayout 的更多信息,请查看 android 文档。

      【讨论】:

        猜你喜欢
        • 2012-02-01
        • 1970-01-01
        • 2011-09-17
        • 2015-05-14
        • 2018-01-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-13
        相关资源
        最近更新 更多