Skip to content Skip to sidebar Skip to footer

Search-view Not Working Correctly In Android Toolbar

I am using search view in my Flickr app but when I run, it just display the title of search view not it's search icon and when I click on the title it should display and area to ty

Solution 1:

As Commented You need to write android:support.v7.widget.SearchView to address the appropriate class naming convention

and also add collapseActionView| for collapsing feature

<item
        android:id="@+id/menu_item_search"
        android:title="@string/search"
        app:actionViewClass="android:support.v7.widget.SearchView"
        app:showAsAction="collapseActionView|ifRoom"/>

Solution 2:

I have changed the version of appcompact library to 25.3.0 and it solved

I think the library was corrupted.

this is the code of my gradle

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile'com.android.support:appcompat-v7:25.3.0'
    testCompile 'junit:junit:4.12'compile'com.android.support:recyclerview-v7:25.3.0'
}

Solution 3:

change this use android:support.v7.widget.SearchView instedof android:support.v7.widget.searchView

<item
   android:id="@+id/menu_item_search"
   android:title="@string/search"
   app:actionViewClass="android:support.v7.widget.SearchView"
   app:showAsAction="ifRoom"/>

Post a Comment for "Search-view Not Working Correctly In Android Toolbar"