【问题标题】:How can I get the selected item in an edit-text and show that item within a rectangle box with cross symbol如何在编辑文本中获取所选项目并在带有十字符号的矩形框中显示该项目
【发布时间】:2017-10-12 14:38:32
【问题描述】:

我正在开发一个消息应用程序,为此,我想在 Edit-Text 中显示选定的联系人,如下图所示。见下图,上方的编辑文本在一个带有十字符号的小矩形框中显示联系人姓名以将其删除。

我怎样才能做出这样的设计,任何建议或技巧都会有所帮助。

【问题讨论】:

  • 到目前为止你做了什么?

标签: android android-layout android-edittext


【解决方案1】:

这可以通过使用谷歌最近为 Android 平台推出的 Google 的 FlexBoxLayout 来实现。

https://github.com/google/flexbox-layout

要做的步骤:

1) 在 gradle 中添加 Flexbox 依赖。

dependencies {
compile 'com.google.android:flexbox:0.3.1'
}

2) 获取一个 recyclerview 并根据您的需要设计其项目并制作一个 recycler Adapter。

3) 使用 FlexboxLayoutManager 设置 recyclerview 的 layoutmanager。

RecyclerView recyclerView = (RecyclerView)context.findViewById(R.id.recyclerview);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
recyclerview.setLayoutManager(layoutmanager);
recyclerView.setAdapter(demoAdapter);

然后你就可以走了。 :) 快乐编码...

【讨论】:

  • 感谢领导先生 SK
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多