gpt4 book ai didi

android - 左侧带有提示和搜索图标的搜索框

转载 作者:行者123 更新时间:2023-11-30 01:57:02 24 4
gpt4 key购买 nike

我想创建一个searchview,它应该有一个搜索图标和提示(如在EditText 中)。 android 中的默认搜索 View 只有搜索图标。它没有像 edittext 那样的提示。

我可以向 searchview 添加提示,但它只有在单击搜索 View 上的搜索图标后才可见。我正在使用以下代码向搜索 View 添加提示。

String locationSearchViewSetQueryHint = "<font color = #ffffff>Location</font>" 
locationSearchView.setQueryHint(Html.fromHtml(locationSearchViewSetQueryHint))

如何显示带有搜索图标的提示?

最佳答案

试一试对我有用,

 <SearchView
android:id="@+id/sv_full_list_symbols"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:gravity="center"
android:queryHint="@string/R471"
android:textColor="@color/white"
android:textSize="14sp" >
</SearchView>

将此添加到您的代码中,

fullSearchView = (SearchView) findViewById(R.id.sv_full_list_symbols);
SearchManager searchManager1 = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
fullSearchView.setSearchableInfo(searchManager1.getSearchableInfo(getComponentName()));
fullSearchView.setIconifiedByDefault(false);

快乐编码...

关于android - 左侧带有提示和搜索图标的搜索框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32064877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com