如何在操作栏中构建类似 Gmail 的搜索框?

     2023-03-05     283

关键词:

【中文标题】如何在操作栏中构建类似 Gmail 的搜索框?【英文标题】:How to build Gmail like search box in the action bar? 【发布时间】:2013-09-22 23:29:35 【问题描述】:

我目前在ActionBarcompat 中使用SearchView 小部件在搜索时过滤列表。

当用户开始输入文本时,主布局中的 ListView 会使用 Adapter 更新以过滤结果。我通过实现OnQueryTextListener 并过滤每个击键的结果来做到这一点。

相反,我想创建一个类似 Gmail 的搜索框,并生成自动建议列表并且不更改底层视图

我已经使用了SearchView 组件的this tutorial,但它需要可搜索 活动。我希望下拉菜单位于我拥有 ListView(如在 Gmail 应用程序中)的 MainActivity 上方,而不是专用的 Activity。 此外,以与教程中相同的方式实现它似乎对我想要的东西来说有点过头了(只是一个下拉菜单)

【问题讨论】:

【参考方案1】:

如果您只想要一个执行问题中描述的组件,我建议您使用library。您也可以实现 out-of-the-bx searchable interface,但是请注意它确实有 UI 限制:

要实现类似于 Gmail 应用程序的界面,您必须了解以下概念:

内容提供者; 在 SQLite 中持久化数据 Listview 或 RecyclerView 及其适配器; 在活动之间传递数据;

最终结果应该类似于:

有很多(许多)方法可以达到相同(或更好)的结果,我将描述一种可能的方法。

第 1 部分:布局

我决定在一个新的 Activity 中管理整个界面,为此我创建了三个 XML 布局:

custom_searchable.xml:将所有 UI 元素组合到一个 RelativeLayout 中,作为 SearchActivity 的内容;

<include
    android:id="@+id/cs_header"
    layout="@layout/custom_searchable_header_layout" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/cs_result_list"
    android:layout_
    android:layout_
    android:stackFromBottom="true"
    android:transcriptMode="normal"/>

custom_searchable_header_layout.xml:保存用户输入查询的搜索栏。它还将包含麦克风、擦除和返回 btn;

<RelativeLayout
    android:id="@+id/custombar_return_wrapper"
    android:layout_
    android:layout_
    android:gravity="center_vertical"
    android:background="@drawable/right_oval_ripple"
    android:focusable="true"
    android:clickable="true" >

    <ImageView
        android:id="@+id/custombar_return"
        android:layout_
        android:layout_
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:background="#00000000"
        android:src="@drawable/arrow_left_icon"/>
</RelativeLayout>

<android.support.design.widget.TextInputLayout
    android:layout_
    android:layout_
    android:layout_toRightOf="@+id/custombar_return_wrapper"
    android:layout_marginRight="60dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp">

    <EditText
        android:id="@+id/custombar_text"
        android:layout_
        android:layout_
        android:hint="Search..."
        android:textColor="@color/textPrimaryColor"
        android:singleLine="true"
        android:imeOptions="actionSearch"
        android:background="#00000000">
        <requestFocus/>
    </EditText>

</android.support.design.widget.TextInputLayout>

<RelativeLayout
    android:id="@+id/custombar_mic_wrapper"
    android:layout_
    android:layout_
    android:layout_alignParentRight="true"
    android:gravity="center_vertical"
    android:background="@drawable/left_oval_ripple"
    android:focusable="true"
    android:clickable="true" >

    <ImageView
        android:id="@+id/custombar_mic"
        android:layout_
        android:layout_
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:background="#00000000"
        android:src="@drawable/mic_icon"/>
</RelativeLayout>

custom_searchable_row_details.xml:持有待显示在结果列表中的UI元素,以响应用户查询;

<ImageView
    android:id="@+id/rd_left_icon"
    android:layout_
    android:layout_
    android:layout_marginTop="3dp"
    android:layout_centerVertical="true"
    android:layout_marginLeft="5dp"
    android:src="@drawable/clock_icon" />

<LinearLayout
    android:id="@+id/rd_wrapper"
    android:orientation="vertical"
    android:layout_
    android:layout_
    android:gravity="center_vertical"
    android:layout_toRightOf="@+id/rd_left_icon"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="50dp">

    <TextView
        android:id="@+id/rd_header_text"
        android:layout_
        android:layout_
        android:textColor="@color/textPrimaryColor"
        android:text="Header"
        android:textSize="16dp"
        android:textStyle="bold"
        android:maxLines="1"/>

    <TextView
        android:id="@+id/rd_sub_header_text"
        android:layout_
        android:layout_
        android:textColor="@color/textPrimaryColor"
        android:text="Sub Header"
        android:textSize="14dp"
        android:maxLines="1" />
</LinearLayout>

<ImageView
    android:id="@+id/rd_right_icon"
    android:layout_
    android:layout_
    android:layout_marginTop="3dp"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:src="@drawable/arrow_left_up_icon"/>

第 02 部分:实现 SearchActivity

​​>

这个想法是,当用户键入搜索按钮(您可以将其放置在您想要的任何位置)时,将调用此 SearchActivity。它有一些主要职责:

绑定到custom_searchable_header_layout.xml 中的UI 元素:这样做是可能的:

为 EditText 提供侦听器(用户将在其中键入他的查询):

TextView.OnEditorActionListener searchListener = new TextView.OnEditorActionListener() 
public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) 
    // do processing
   


searchInput.setOnEditorActionListener(searchListener);

searchInput.addTextChangedListener(new TextWatcher()         
public void onTextChanged(final CharSequence s, int start, int before, int count) 
     // Do processing
   

为返回按钮添加监听器(它只会调用finish()并返回到调用者活动):

this.dismissDialog.setOnClickListener(new View.OnClickListener() 
    public void onClick(View v) 
    finish();
    

调用谷歌语音转文本 API 的意图:

    private void implementVoiceInputListener () 
        this.voiceInput.setOnClickListener(new View.OnClickListener() 

            public void onClick(View v) 
                if (micIcon.isSelected()) 
                    searchInput.setText("");
                    query = "";
                    micIcon.setSelected(Boolean.FALSE);
                    micIcon.setImageResource(R.drawable.mic_icon);
                 else 
                    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

                    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak now");

                    SearchActivity.this.startActivityForResult(intent, VOICE_RECOGNITION_CODE);
                
            
        );
    

内容提供者

在构建搜索界面时,开发人员通常有两种选择:

    向用户建议最近的查询:这意味着每次用户进行搜索时,键入的查询都将保存在数据库中,以便以后检索作为未来搜索的建议; 向用户建议自定义选项:开发人员将尝试通过处理已经输入的字母来预测用户想要什么;

在这两种情况下,答案都应作为 Cursor 对象返回,该对象的内容将在结果列表中显示为 itens。这整个过程可以使用 Content Provider API 来实现。有关如何使用 Content Providers 的详细信息,请访问此link。

在开发者想要实现 1. 中描述的行为的情况下,使用扩展 SearchRecentSuggestionsProvider 类的策略会很有用。可以在此link 中获得有关如何操作的详细信息。

实现搜索界面

此接口应提供以下行为:

当用户键入一个字母时,对检索到的内容提供程序类的查询方法的调用应该返回一个填充的光标,其中包含要显示在列表中的建议 - 你应该注意不要冻结 UI 线程,所以我建议在 AsyncTask 中执行此搜索:

    public void onTextChanged(final CharSequence s, int start, int before, int count) 
        if (!"".equals(searchInput.getText().toString())) 
            query = searchInput.getText().toString();

            setClearTextIcon();

            if (isRecentSuggestionsProvider) 
                // Provider is descendant of SearchRecentSuggestionsProvider
                mapResultsFromRecentProviderToList(); // query is performed in this method
             else 
                // Provider is custom and shall follow the contract
                mapResultsFromCustomProviderToList(); // query is performed in this method
            
         else 
            setMicIcon();
        
    

在 AsyncTask 的 onPostExecute() 方法中,您应该检索一个列表(应该来自 doInBackground() 方法),其中包含要在 ResultList 中显示的结果(您可以将它映射到 POJO 类中并传递它到您的自定义适配器,或者您可以使用 CursorAdapter 这将是此任务的最佳实践):

protected void onPostExecute(List resultList) 
     SearchAdapter adapter = new SearchAdapter(resultList);
     searchResultList.setAdapter(adapter);


protected List doInBackground(Void[] params) 
    Cursor results = results = queryCustomSuggestionProvider();
    List<ResultItem> resultList = new ArrayList<>();

    Integer headerIdx = results.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
    Integer subHeaderIdx = results.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2);
    Integer leftIconIdx = results.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1);
    Integer rightIconIdx = results.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2);

    while (results.moveToNext()) 
        String header = results.getString(headerIdx);
        String subHeader = (subHeaderIdx == -1) ? null : results.getString(subHeaderIdx);
        Integer leftIcon = (leftIconIdx == -1) ? 0 : results.getInt(leftIconIdx);
        Integer rightIcon = (rightIconIdx == -1) ? 0 : results.getInt(rightIconIdx);

        ResultItem aux = new ResultItem(header, subHeader, leftIcon, rightIcon);
        resultList.add(aux);
    

    results.close();
    return resultList;

识别用户何时从软键盘触摸搜索按钮。当他这样做时,向可搜索的活动(负责处理搜索结果的活动)发送一个意图,并将查询作为额外信息添加到意图中

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) 
        case VOICE_RECOGNITION_CODE: 
            if (resultCode == RESULT_OK && null != data) 
                ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                searchInput.setText(text.get(0));
            
            break;
        
    

识别用户何时点击显示的建议之一并发送包含项目信息的意图(此意图应不同于上一步的意图)

private void sendSuggestionIntent(ResultItem item) 
    try 
        Intent sendIntent = new Intent(this, Class.forName(searchableActivity));
        sendIntent.setAction(Intent.ACTION_VIEW);
        sendIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

        Bundle b = new Bundle();
        b.putParcelable(CustomSearchableConstants.CLICKED_RESULT_ITEM, item);

        sendIntent.putExtras(b);
        startActivity(sendIntent);
        finish();
     catch (ClassNotFoundException e) 
        e.printStackTrace();
    

所描述的步骤应该足以实现您自己的接口。所有代码示例均取自here。我已经制作了这个库,它可以完成上述大部分内容。它尚未经过良好测试,并且某些 UI 配置可能尚不可用。

我希望这个答案可以帮助有需要的人。

【讨论】:

这里的新问题:在 custom_searchable_header_layout.xml 中,你为什么将东西包装在包装器中。为什么在 LinearLayout 或 RelativeLayout 中没有 ImageView、EditText 和 ImageView? 如果我没记错的话,我这样做是为了应用到 RelativeLayout 的涟漪效应。 tnx 为您解答。一件事我不明白。你为什么使用内容提供者而不是“@Doa”和存储库模式?因为在我们的应用程序的数据库中保存一些东西不需要使用内容提供者。我猜你回答问题的时间是“@Doa”和存储库模式没有在 android 中使用或呈现。【参考方案2】:

我为此设置了一个小教程

http://drzon.net/how-to-create-a-clearable-autocomplete-dropdown-with-autocompletetextview/

概述

我不得不按照建议将SearchView 替换为AutoCompleteTextView

首先,创建一个适配器。在我的例子中,它是一个JSONObject ArrayAdapter。我想在下拉列表中显示的数据是场地名称和场地地址。请注意,适配器必须是Filtarable 并覆盖getFilter()

// adapter for the search dropdown auto suggest
ArrayAdapter<JSONObject> searchAdapter = new ArrayAdapter<JSONObject>(this, android.R.id.text1) 
private Filter filter;

public View getView(final int position, View convertView, ViewGroup parent) 
    if (convertView == null) 
        convertView = this.getLayoutInflater().inflate(R.layout.search_item, parent, false);
    

    TextView venueName = (TextView) convertView.findViewById(R.id.search_item_venue_name);
    TextView venueAddress = (TextView) convertView.findViewById(R.id.search_item_venue_address);

    final JSONObject venue = this.getItem(position);
    convertView.setTag(venue);
    try 

        CharSequence name = highlightText(venue.getString("name"));
        CharSequence address = highlightText(venue.getString("address"));

        venueName.setText(name);
        venueAddress.setText(address);
    
    catch (JSONException e) 
        Log.i(Consts.TAG, e.getMessage());
    

    return convertView;



@Override
public Filter getFilter() 
    if (filter == null) 
        filter = new VenueFilter();
    
    return filter;

;

这是自定义的VenueFilter

private class VenueFilter extends Filter 

    @Override
    protected FilterResults performFiltering(CharSequence constraint) 
        List<JSONObject> list = new ArrayList<JSONObject>(venues);
        FilterResults result = new FilterResults();
        String substr = constraint.toString().toLowerCase();

        if (substr == null || substr.length() == 0) 
            result.values = list;
            result.count = list.size();
         else 

            final ArrayList<JSONObject> retList = new ArrayList<JSONObject>();
            for (JSONObject venue : list) 
                try 
                    if (venue.getString("name").toLowerCase().contains(constraint) ||  venue.getString("address").toLowerCase().contains(constraint) || 
                         
                        retList.add(venue);
                    
                 catch (JSONException e) 
                    Log.i(Consts.TAG, e.getMessage());
                
            
            result.values = retList;
            result.count = retList.size();
        
        return result;
    

    @SuppressWarnings("unchecked")
    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) 
        searchAdapter.clear();
        if (results.count > 0) 
            for (JSONObject o : (ArrayList<JSONObject>) results.values) 
                searchAdapter.add(o);
            
        
    


现在设置搜索框的布局 (actionbar_search.xml):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_
    android:layout_
    android:layout_gravity="fill_horizontal"
    android:focusable="true" >

    <AutoCompleteTextView
        android:id="@+id/search_box"
        android:layout_
        android:layout_
        android:layout_gravity="center"
        android:dropDownVerticalOffset="5dp"
        android:dropDownWidth="wrap_content"
        android:inputType="textAutoComplete|textAutoCorrect"
        android:popupBackground="@color/white"
        android:textColor="#FFFFFF" >
    </AutoCompleteTextView>

</RelativeLayout>

以及单个下拉项目的布局(场地名称和场地地址)。这个看起来很糟糕,你必须自定义它:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_
    android:layout_
    android:textAlignment="gravity" >

    <TextView
        android:id="@+id/search_item_venue_name"
        android:layout_
        android:layout_
        android:textColor="@color/cyan"
        android:layout_gravity="right" />

    <TextView
        android:id="@+id/search_item_venue_address"
        android:layout_
        android:layout_
        android:layout_toStartOf="@+id/search_item_venue_name"
        android:gravity="right"
        android:textColor="@color/white" />


</RelativeLayout>

接下来我们要把它放到操作栏中

@Override
public void onCreate(Bundle savedInstanceState) 
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_HOME_AS_UP);
    LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.actionbar_search, null);
    AutoCompleteTextView textView =  (AutoCompleteTextView) v.findViewById(R.id.search_box);

    textView.setAdapter(searchAdapter);

    textView.setOnClickListener(new View.OnClickListener() 

        @Override
        public void onClick(View v) 
            // do something when the user clicks
        
    );
    actionBar.setCustomView(v);

就是这样,我还有一些事情要弄清楚:

这会在操作栏中放置一个“始终存在”搜索,我希望它像 SearchView 小部件 - 一个放大镜,当您单击它时会打开一个搜索框(并且有一点 X按钮将其关闭并恢复正常) 还没想好怎么自定义下拉框,比如Gmail的好像有阴影,我的是平的,换行分隔符的颜色等等...

总体而言,这节省了创建可搜索活动的所有开销。如果您知道如何自定义它等,请添加。

【讨论】:

能否提供项目的github链接?【参考方案3】:

如果您只想实现下拉效果,请选择AutoCompleteTextView

你可以找到一个很好的教程here

如果你想实现精确的设计,你必须实现ActionBar 如果你想实现更低版本,你需要实现ActionBarCombat 而不是 ActionBar

【讨论】:

谢谢,忘了说我已经在用ActionBarCompat【参考方案4】:

您应该使用ListPopupWindow 并将其锚定到搜索视图小部件。

【讨论】:

【参考方案5】:

我已成功使用 Michaels 回复 (https://***.com/a/18894726/2408033),但我不喜欢它的手动方式、膨胀视图并将其添加到操作栏、切换其状态等。

我将其修改为使用 ActionBar ActionView 而不是手动将视图添加到操作栏/工具栏。

我发现这工作得更好,因为我不需要像他在添加链接的 toggleSearch 方法的示例中那样管理视图的打开/关闭状态和隐藏。它还可以与后退按钮完美配合。

在我的 menu.xml 中

 <item
        android:id="@+id/global_search"
        android:icon="@android:drawable/ic_menu_search"
        android:title="Search"
        app:actionLayout="@layout/actionbar_search"
        app:showAsAction="ifRoom|collapseActionView" />

在我的 onCreateOptionsMenu 中

 View actionView = menu.findItem(R.id.global_search).getActionView();
 searchTextView = (ClearableAutoCompleteTextView) actionView.findViewById(R.id.search_box);
 searchTextView.setAdapter(searchAdapter);

您可以在我的项目中找到该实现的完整工作版本。请注意,当我使用实际的 SearchView 过滤 listView 时,有两个搜索视图。

https://github.com/babramovitch/ShambaTimes/blob/master/app/src/main/java/com/shambatimes/schedule/MainActivity.java

【讨论】:

【参考方案6】:

请参阅此示例,该示例完全实现了您的要求: http://wptrafficanalyzer.in/blog/android-searchview-widget-with-actionbarcompat-library/

【讨论】:

【参考方案7】:

你需要使用collapseActionView属性。

collapseActionView 属性允许您的 SearchView 扩展到 占据整个动作栏并折叠回正常状态 不使用时的操作栏项目。

例如:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/search"
          android:title="@string/search_title"
          android:icon="@drawable/ic_search"
          android:showAsAction="collapseActionView|ifRoom"
          android:actionViewClass="android.widget.SearchView" />
</menu>

【讨论】:

如何在 Bootstrap 3 的导航栏中添加带有图标的搜索框?

】如何在Bootstrap3的导航栏中添加带有图标的搜索框?【英文标题】:HowtoaddasearchboxwithicontothenavbarinBootstrap3?【发布时间】:2013-09-0807:24:42【问题描述】:我正在使用新的TwitterBootstrap3,并尝试将这样的搜索框(如下)放在顶部导... 查看详情

Swift 如何从我在搜索栏中定义的地图项构建路线

】Swift如何从我在搜索栏中定义的地图项构建路线【英文标题】:SwiftHowtobuildarouteFROMmapItem,whichIdefineinSearchBar【发布时间】:2020-05-1012:03:06【问题描述】:对不起,如果主题不是那么准确。我正在尝试构建从点到点的地图路线,... 查看详情

如何创建仅在主题行开头搜索文本的 Gmail 过滤器?

】如何创建仅在主题行开头搜索文本的Gmail过滤器?【英文标题】:HowtocreateGmailfiltersearchingfortextonlyatstartofsubjectline?【发布时间】:2012-08-2802:43:18【问题描述】:我们会定期收到来自工作中Jenkins构建服务器的自动构建消息。最好... 查看详情

如何在 bootstrap 3 导航栏中使 select2 v4 搜索框响应?

】如何在bootstrap3导航栏中使select2v4搜索框响应?【英文标题】:Howtomakeselect2v4searchboxesresponsiveinthebootstrap3navbar?【发布时间】:2015-08-0316:45:55【问题描述】:我在bootstrap3导航栏中放置了select2搜索框。问题是当我调整浏览器大小... 查看详情

如何在搜索栏中获取项目的详细信息?

】如何在搜索栏中获取项目的详细信息?【英文标题】:Howtogettheitem\'sdetailsinsearchbar?【发布时间】:2021-09-0921:36:40【问题描述】:我正在使用ASP.NETCoreMVC构建电子商务Web应用程序。我的_layout页面上有一个搜索栏。我想显示商品... 查看详情

如何更改 wordpress 搜索栏中的搜索操作?

】如何更改wordpress搜索栏中的搜索操作?【英文标题】:Howtochangethesearchactioninwordpresssearchbar?【发布时间】:2019-05-2117:03:01【问题描述】:创建一个新帖子并发布它。标题为mytestforsearch,内容如下:nohostroute检查wordpress数据库中... 查看详情

如何在 twitter bootstrap3 的导航栏中增加搜索栏的宽度

】如何在twitterbootstrap3的导航栏中增加搜索栏的宽度【英文标题】:Howtoincreasethewidthofsearchbarinthenavbarintwitterbootstrap3【发布时间】:2013-09-2912:49:25【问题描述】:我无法在twitterbootstrap3中增加导航栏搜索框的大小。我曾尝试将它们... 查看详情

仅在父片段中的操作栏中显示搜索视图

...ent【发布时间】:2018-06-1722:44:00【问题描述】:我想知道如何仅在父片段中在操作栏中显示搜索视图。现在,当我从操作栏中的searchview提交搜索并转到下一个片段时,我仍然可以在我的子片段中看到searchview。有什么建议可以解... 查看详情

facebook/gmail 类似的网络聊天框 - 现在的聊天应用程序存储短信的好方法是啥?

...【发布时间】:2013-06-2408:20:04【问题描述】:我目前正在构建一个类似f 查看详情

导航栏中的 iOS 搜索栏

...在说什么。我已经看到了大量的指南和教程,它们展示了如何在表格视图中实现类似的东西,但这不是我想要做的。谁能告诉我最好 查看详情

如何使用 Bootstrap 构建动态搜索框

】如何使用Bootstrap构建动态搜索框【英文标题】:HowtobuilddynamicsearchboxusingBootstrap【发布时间】:2020-07-0301:14:04【问题描述】:我目前在支持Angular的Servicenow服务门户工作我可以使用bootstrap创建一个搜索框,如下所示:<selectclass... 查看详情

Nativescript - 搜索栏在操作栏中无法正确显示(IOS)

】Nativescript-搜索栏在操作栏中无法正确显示(IOS)【英文标题】:Nativescript-SearchBardoesnotdisplaycorrectlywithinactionbar(IOS)【发布时间】:2017-07-2611:55:25【问题描述】:我正在创建一个nativescriptAngular应用程序。在为我的应用创建搜索... 查看详情

如何在类似于 Gmail 的某个 ListView 项目之后添加分隔符

】如何在类似于Gmail的某个ListView项目之后添加分隔符【英文标题】:HowtoadddividerafteracertainListViewitemsimilartoGmail【发布时间】:2019-09-0304:06:20【问题描述】:与Gmail的做法类似,我想在(在我的情况下)第二项之后在我的导航抽屉... 查看详情

如何更改 SearchView 上的默认图标,以便在 Android 的操作栏中使用?

】如何更改SearchView上的默认图标,以便在Android的操作栏中使用?【英文标题】:HowtochangethedefaulticonontheSearchView,tobeuseintheactionbaronAndroid?【发布时间】:2012-05-1319:36:24【问题描述】:我在自定义SearchView中的搜索图标时遇到了一些... 查看详情

如何在搜索栏中保留搜索到的单词?

】如何在搜索栏中保留搜索到的单词?【英文标题】:Howtokeepsearchedwordsinsearchbar?【发布时间】:2017-05-2209:25:11【问题描述】:我在应用中有搜索栏。场景是我在第一次运行应用程序时搜索“树”。第二次,我第三次搜索“橙子... 查看详情

操作栏中的搜索小部件中的提示未显示

】操作栏中的搜索小部件中的提示未显示【英文标题】:HintinSearchWidgetwithinActionBarisnotshowingup【发布时间】:2013-12-0315:42:16【问题描述】:我在操作栏中有一个搜索小部件。我已经设置了一个android:hint值但是当我点击搜索图标时... 查看详情

无法让操作栏中的搜索视图工作

】无法让操作栏中的搜索视图工作【英文标题】:Cannotgetsearchviewinactionbartowork【发布时间】:2012-07-2619:19:18【问题描述】:我对java和android开发很陌生;我一直在开发一个应用程序,我想要一个带有SearchView的操作栏。我看过谷歌... 查看详情

从 android 上的操作栏中删除图标/徽标

...Android的文档和Google一个小时后,我发现的唯一一件事是如何完全删除标题栏.那不是我想要的。只想从标题栏中删除图标/徽标。任何人都知道如何做到这一点?最好我想在XML中执 查看详情