能够自动完成一的EditText preference? [英] Possible to autocomplete a EditTextPreference?

查看:98
本文介绍了能够自动完成一的EditText preference?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能与自动完成一个EditText preference重视它?

我知道浩附加一个元素与一个id,但我有麻烦弄清楚如何将一个ArrayAdapter附加到preference领域。

这是错的,但它是尽可能靠近我可以得到的。

 最终的String [] = TEAMS getResources()getStringArray(R.array.teams)。
AutoCompleteTextView的EditText preference =(AutoCompleteTextView)findViewById(R.id.editText prefTeam);
ArrayAdapter适配器=新ArrayAdapter(这一点,android.R.layout.simple_dropdown_item_1line,队);
的EditText preference.setAdapter(适配器);


解决方案

也许,如果你继承它,使自己的观点为,并使用AutoCompleteTextView对象作为元素,它将工作,因为目前我看不出一个简单的EditText上可改为自动完成。

Is it possible to have an EditTextPreference with AutoComplete attached to it?

I know ho to attach one to an element with an id, but am having trouble figure out how to attach the ArrayAdapter to the preference field.

This is wrong, but it's as close as I can get.

final String[] TEAMS = getResources().getStringArray(R.array.teams);   
AutoCompleteTextView EditTextPreference = (AutoCompleteTextView) findViewById(R.id.editTextPrefTeam);     
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, TEAMS);
EditTextPreference.setAdapter(adapter);

解决方案

Probably if you subclass it and make your own view for that and use the AutoCompleteTextView object as element it will work, as currently I don't see how a simple EditText can be changed to autocomplete.

这篇关于能够自动完成一的EditText preference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆