删除AutoCompleteTextView下拉列表的分隔符

4

在我的应用程序中,我正在使用AutoCompleteTextView。 其中一个要求是隐藏分隔符。 我已经将AutoCompleteTextView添加到布局中:

 <AutoCompleteTextView
android:id="@id/address_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@id/address_operation_btn"
android:background="@null"
android:completionThreshold="1"
android:dropDownAnchor="@id/anchor"
android:dropDownVerticalOffset="13dp"
android:dropDownWidth="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:layout_centerHorizontal="true"
android:hint="@string/address_bar_hint"
android:imeOptions="actionGo"
android:inputType="textUri"
android:maxLines="1"
android:saveEnabled="true"
android:singleLine="true"
android:dropDownListViewStyle="@style/searchResultsList"
android:textColor="@android:color/white"
android:textColorHint="#80FFFFFF"
android:textSize="17sp" />

我使用的样式是:
    <style name="searchResultsList" parent="@android:style/Widget.ListView">
    <item name="android:divider">@android:color/transparent</item>
    <item name="android:dividerHeight">0px</item>
</style>

但是分隔符仍然存在...如何隐藏它呢?


这个例子可能会有所帮助:http://www.codeofaninja.com/2013/12/android-autocompletetextview-custom-arrayadapter-sqlite.html - Shabbir Dhangot
http://www.javatpoint.com/android-autocompletetextview-example 这个也是。 - Shabbir Dhangot
1个回答

10

使用您的应用程序主题进行覆盖。在您的themes.xml

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
  <item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
</style>

<style name="DropDownListViewStyle" parent="@style/Widget.AppCompat.ListView.DropDown">
  <item name="android:divider">@android:color/transparent</item>
  <item name="android:dividerHeight">0dp</item>
</style>

致谢:http://daniel-codes.blogspot.com/2012/11/styling-autocompletetextview.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接