gpt4 book ai didi

android - Gmail like contact selector/tag cloud/chip cloud with profile image 安卓

转载 作者:行者123 更新时间:2023-11-29 19:38:23 24 4
gpt4 key购买 nike

我的目标

enter image description here

创建一个联系人选择器(左边有圆形图像),就像 gmail 在发送电子邮件时所做的那样。我做了一些研究,找到了 EditText 云和 Chip 云,但它们不支持自定义布局中的图像,适配器只接受 List<String> .有人对如何实现这个或使用库来实现这个有正确的想法吗?

提前致谢。

最佳答案

我建议你使用TokenAutoComplete

public class ContactsCompletionView extends TokenCompleteTextView<Person> {
public ContactsCompletionView(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
protected View getViewForObject(Person person) {

LayoutInflater l = (LayoutInflater) getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
TextView view = (TextView) l.inflate(R.layout.contact_token, (ViewGroup) getParent(), false);
view.setText(person.getEmail());

return view;
}

@Override
protected Person defaultObject(String completionText) {
//Stupid simple example of guessing if we have an email or not
int index = completionText.indexOf('@');
if (index == -1) {
return new Person(completionText, completionText.replace(" ", "") + "@example.com");
} else {
return new Person(completionText.substring(0, index), completionText);
}
}
}

输出:

enter image description here

关于android - Gmail like contact selector/tag cloud/chip cloud with profile image 安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38996009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com