Gmail的接触等选择器/标签云/芯片云与轮廓图像的Android
问题描述:
我的目标Gmail的接触等选择器/标签云/芯片云与轮廓图像的Android
要创建联系人选择器(上左圆图),如Gmail发送电子邮件时不。我已经做了一些研究,发现EditText云和芯片云,但他们不支持定制布局中的图像,并且适配器只接受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);
}
}
}
OUTPUT:
关闭,但我真的希望它与名称左侧的形象图。 – jobbert
啊,我在layoutinflater中得到它。 – jobbert
@jobbert确定接受它,如果它帮助:) –