【问题标题】:How to create a gridview like Foursquare interest selection screen?如何创建类似 Foursquare 兴趣选择屏幕的 gridview?
【发布时间】:2015-03-18 19:15:03
【问题描述】:

我正在创建一个需要用户选择多个兴趣的应用。 我正在尝试创建一个类似于 Foursquare 兴趣选择的屏幕类似于标签云,其中可以选择多个按钮来代表用户的兴趣。

我已经尝试创建一个gridview,但我无法实现按钮包裹到下一行的效果。

有没有办法通过 gridview 来实现?有没有做这种 UI 的库?

【问题讨论】:

  • 在 GitHub 上寻找 FlowLayout
  • @Vikram 这看起来像 github.com/blazsolar/FlowLayout 你能把这个作为答案发布,以便我可以接受它作为答案。

标签: android user-interface gridview foursquare tag-cloud


【解决方案1】:

这个 repo 可能会对某人有所帮助。 https://github.com/Cutta/TagView

【讨论】:

    【解决方案2】:

    您正在寻找FlowLayoutgravity="center_horizontal"。有几种可用的实现,其中很多是 GitHub 上的库项目。随你挑:)

    ApmeM/android-flowlayout

    blazsolar/FlowLayout

    suanmiao/flowlayout

    (降序 *s)

    【讨论】:

    • 非常感谢您多花几分钟的时间。非常感谢。
    • @manishKungwani,如何在 Eclipse 项目中使用它?有eclipse版本吗?
    • @user2459623 您希望使用哪个特定库?理想情况下,如果项目编译为 jar,您可以直接导入该 jar 或修改项目以生成 jar。
    • 现在我可以将它们包含在 eclipse 中,并且在通过顶部的编辑文本进行过滤时遇到问题,知道吗?因为我这里没有使用适配器。
    【解决方案3】:

    您好,还有另一个使用 custom Library 的示例,其作用类似于 List GitHubLibrary TagLayout

    • 示例代码:-

    mFlowLayout.setAdapter(new TagAdapter<String>(mVals) { @Override public View getView(FlowLayout parent, int position, String s) { TextView tv = (TextView) mInflater.inflate(R.layout.tv, mFlowLayout, false); tv.setText(s); return tv; } });

    使用下面的代码,您可以预先设置您想要的选择:-

    mAdapter.setSelectedList(1,3,5,7,8,9);
    

    【讨论】:

      【解决方案4】:

      您可以尝试使用带有重力=“中心”的线性布局。如果这对您不起作用,那么也许编写您自己的自定义布局来执行线性布局、环绕和居中。

      对于前者,请参阅this post 的示例。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-11-08
        • 1970-01-01
        • 1970-01-01
        • 2016-08-18
        • 2016-04-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多