developer

Customize

The Yahoo Search SDK allows developers to customize the look and feel of UI components, including the Search Bar, Tab Bar, background, and progress bar.

Customized Tab bar

The tab bar is TabLayout widget from android design support library. All the styling attributes of TabLayout is supported. All you have to do is override the Search SDK style name Yhssdk_TabLayout as below. Refer styles xml file in the demo app.

<style name="Yhssdk_TabLayout" parent="Base.Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/button_material_light</item>
</style>

Customized Search Assist Layout

The Yahoo Search SDK provides default search suggestions/assist view. To customize suggestions view follow these steps.

  1. Create a Data binding layout file that contains variables for SearchAssistData and click handler callback methods onClickAssistItem & onAppendSuggestionItem in SearchActivity:

    <layout
    xmlns:android="http://schemas.android.com/apk/res/android">
    <data>
        <variable
            name="assist"
            type="com.yahoo.search.yhssdk.data.SearchAssistData"/>
        <variable
            name="handler"
            type="com.yahoo.search.yhssdk.ui.view.SearchActivity"/>
    </data>
    <!--YOUR VIEW CONTENT HERE-->
    </layout>
    
  2. Pass your layout file as a parameter to the SearchActivity using the builder.

    SearchActivity.IntentBuilder builder = new SearchActivity.IntentBuilder();
    builder.setCustomSearchAssist(R.layout.custom_search_assist_item);
    Intent intent = builder.buildIntent(YourActivity.this);
    startActivity(intent);
    
  3. SearchAssistData object fields:

    type - Integer constant that specifies the suggestion type. Below are the different types of suggestions.

    SEARCH_HISTORY   - The suggestion is a history item from the user previous query searches.
    SEARCH_APPS      - App suggestion from the phone that matches the user query.
    SEARCH_CONTACTS  - Contact suggestion from the phone that matches the user query.
    SEARCH_SUGGEST   - Typical query suggestion
    LOCAL_WEB        - similar to SEARCH_HISTORY.
    SEARCH_TRENDING  - Trending suggestion.
    SHOW_ALL_HISTORY - Show all history.
    CLEAR_HISTORY    - Clear all history.
    SECTION_DIVIDER  - The section divider between different types of suggestions like Apps,Contacts,history etc.
    
    label - The actual search suggestion text.
    
    icon - The icon to be used for SEARCH_APPS and SEARCH_CONTACTS suggestion.
    
  4. Assist item click handling

    onAppendSuggestionItem callback for the query builder click event. SDK uses this callback to build the query.

    onClickAssistItem callback for the click of search assist item.

You can view more details about the SearchAssistData object and a working CustomSearchAssist demo in the DemoApp.