有没有办法强制autocompletetextview中的条目成为条目列表中的元素之一?
我找到了一个名为"performValidation"的方法,但我不确定它实际上做了什么,而且我还没有找到很多文档或任何示例.
我已经在网站上看到过这个问题,但是没有人能得到任何答案.
在Android中使用AutocompleteTextview时,有没有办法在下拉列表中自定义分隔符的外观?
对于ListView来说很容易,但是对于autocompletetextview只使用ArrayAdapter,有没有办法自定义分隔符.
(不是textview,我已经知道了)
android separator autocompletetextview divider drop-down-menu
AutoCompleteTextView mActv = (AutoCompleteTextView) findViewbyId(R.id.m_actv);
ArrayAdapter<String> AutoCompleteAdapter = new ArrayAdapter<String>(this,
R.layout.dropdown_text, Names);
mActv.setAdapter(AutoCompleteAdapter);
Run Code Online (Sandbox Code Playgroud)
Names是一个String数组.
是否有可能从下拉列表中获取所选文本的索引?
谢谢.
我有条件需要实施自动建议.为此,我一直在尝试使用自定义的RecyclerView.Adapter.但问题是,AutoCompleteTextView似乎是针对BaseAdapter及其子类.
因此,不接受适配器.还有其他方法,我可以使用RecyclerView适配器与AutoCompleteTextView.是否为AutCompleteTextView的ArrayListAdapter或BaseAdapter唯一解决方案?
我想更改默认过滤AutoCompleteTextView.默认筛选查找以给定标记开始的所有字符串.我的项目要求过滤应该找到包含给定标记的所有字符串.
可能吗?
我制作了一个AutoCompletetextView.AutoCompleteTextView下拉列表中的项目不可见.如何更改这些项目的颜色.
这是它的样子: - 
我正在使用自定义适配器与AutoCompleteTextView.它在模拟器和我的平板电脑上工作正常.但是,我的手机在横向模式下出现问题.在此模式下显示的自动完成提示是对象信息而不是文本.但是,当我选择任何项目时,字段会在相应字段中正确填充文本.
基于Android Stock Array Adapter的其他字段的自动完成工作正常.
我必须在自定义适配器中为此做些什么吗?我在SO上只看到了一个类似的问题.对该问题的一个回答是讨论覆盖toString方法,但我无法理解它在我的代码中实现.
任何指导将不胜感激?如果您需要更多信息,请与我们联系.
编辑:添加了我的自定义适配器源代码....
public class Part_Mstr_Info
{
private long part_id;
private String name, desg, org, dept;
public Part_Mstr_Info(long part_id, String name, String desg, String org, String dept)
{
this.part_id = part_id;
this.name = name;
this.desg = desg;
this.org = org;
this.dept = dept;
}
public long get_part_id() { return part_id; }
public String get_name() { return name; }
public String get_desg() { return desg; }
public String get_org() { return org; }
public String get_dept() …Run Code Online (Sandbox Code Playgroud) 对话框弹出窗口位于此处.
自动完成结果如何停在弹出视图的到底是在这里.
我希望结果从对话框的视图下拉到父视图.如果我不能这样做,那么我想限制AutoComplete给我两个结果的数量.
这是我弹出菜单的单击监听器.
addDialog.setContentView(R.layout.shoppinglistadd);
/**Capture the AutoCompleteTextView widget*/
final AutoCompleteTextView autoCompleteTV
= (AutoCompleteTextView) addDialog.findViewById(R.id.productEnteredShop);
/**Fills the autocomplete with possibilities*/
String[] acArray = getResources().getStringArray(R.array.completeFoodsList);
/**Create a new ArrayAdapter and bind shoppinglistitem.xml to each list item*/
ArrayAdapter<String> autoCompleteAdapter
= new ArrayAdapter<String>(ShoppingList.this, R.layout.shoppinglistitem, acArray);
/**Associate the adapter with textView*/
autoCompleteTV.setAdapter(autoCompleteAdapter);
Run Code Online (Sandbox Code Playgroud) 问题描述:
我在AutoCompleteTextView面临一些问题,我必须在每次按键后显示建议.事情是,建议列表是动态像谷歌的建议功能.这意味着应该在用户输入时添加新建议,并且应显示所有匹配的旧建议.
例如
我写"te"然后它应该显示以前的建议,如"test1"和"test2"以及我将从Web API获得的新建议.假设web api给了我"茶"和"紧张"的字样.
现在,AutoCompleteTextView将"te"作为字符串,其下方显示所有四个建议.
这正是我要找的.
看起来很简单,但它显示出一种奇怪的行为.
我正在使用我在全局声明的默认ArrayAdapter类实例.
arrayAdapter=new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,suggestions);
word.setAdapter(arrayAdapter);
Run Code Online (Sandbox Code Playgroud)
建议是ArrayList.
从WebApi获得新结果后,我只需致电
arrayAdapter.notifyDataSetChanged();
Run Code Online (Sandbox Code Playgroud)
刷新数据观察者和附加的视图(在我们的例子中是AutoCompleteListView).
但它结束了建议.
当我不使用notifyDataSetChanged();它时,无论我输入的字符是什么,都会显示所有建议.
我尝试使用自定义过滤器,因为我不能使用notifyDataSetChanged(),但没有一个是有用的.
我发布图片以避免混淆.
我有一个混乱,为什么notifyDataSetChanged();它不起作用.我没有使用相同的arrayAdapter实例的任何其他列表引用.我真的怀疑这是一个参考问题.
android autocompletetextview notifydatasetchanged android-filterable
我正在使用谷歌在我正在进行的项目中提供的PlaceAutocompleteFragment.但问题是我需要显示我从自动完成小部件中选择的地名,但是整个文本没有显示,因为小部件中的默认文本大小太大.那么,有没有什么方法可以在不创建我自己的自定义搜索UI的情况下更改PlaceAutocompleteFragment中的文本大小?
我的XML代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.baldysns.capedbaldy.materialdesigntest.activity.DrawerMainActivity"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:id="@+id/lnr_google_searchbar"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/btn_white_notboerder">
<fragment
android:id="@+id/place_autocompletehome_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="com.ibaax.com.ibaax.FragmentDrawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_drawer"
tools:layout="@layout/fragment_drawer" /></android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
以及问题的截图: