我只是使用带有令牌自动完成视图的EditText
,我希望EditText
输入类型为“手机”
所以我用过..
if (savedInstanceState == null) {
completionView.setPrefix("To: ");
completionView.addObject(people[0]);
completionView.addObject(people[1]);
}
onClick();
adapter.notifyDataSetChanged();
completionView.setInputType(InputType.TYPE_CLASS_PHONE);
它不起作用..需要帮助......提前感谢..
答案 0 :(得分:1)
你必须使用this library,但我没有遇到任何崩溃。
people = new Person[]{
new Person("Margaret Smith", "8888888888888"),
new Person("Max Jordan", "77777777777"),
new Person("Meg Peterson", "666666666666"),
new Person("Amanda Johnson", "555555555555"),
new Person("Terry Anderson", "4444444444444")
};
adapter = new FilteredArrayAdapter<Person>(this, R.layout.person_layout, people) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater l = (LayoutInflater)getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = (View)l.inflate(R.layout.person_layout, parent, false);
}
Person p = getItem(position);
((TextView)convertView.findViewById(R.id.name)).setText(p.getName());
((TextView)convertView.findViewById(R.id.email)).setText(p.getEmail());
return convertView;
}
@Override
protected boolean keepObject(Person obj, String mask) {
mask = mask.toLowerCase();
return obj.getName().toLowerCase().startsWith(mask) || obj.getEmail().toLowerCase().startsWith(mask);
}
};
completionView = (ContactsCompletionView)findViewById(R.id.searchView);
completionView.setAdapter(adapter);
completionView.setTokenListener(this);
if (savedInstanceState == null) {
completionView.setPrefix("To: ");
completionView.addObject(people[0]);
completionView.addObject(people[1]);
}
completionView.setInputType(InputType.TYPE_CLASS_PHONE);
您应该更清楚地提出问题并发布详细信息。