[Android SDK] Important note when creating SearchViews with Android Studio

One of the steps you have to follow when creating a Search interface is this one:

<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/action_search"
          android:title="Search"
          android:icon="@android:drawable/ic_menu_search"
          android:showAsAction="always"
          android:actionViewClass="android.widget.SearchView" />
</menu>`

Note that Android Studio will suggest you to use yourapp:showAsAction instead of android:showAsAction, adding a new xml namespace (xmlns:android=”…” on the root element). DON’T DO THAT if you are not using the android-support-v7-appcompat library! Search view will never be displayed.

Captura de pantalla 2015-02-05 a la(s) 11.30.21

Don’t fix this issue if you are not using android-support-v7-appcompat. Leave the warning unmodified. Hope this saves you all the time i wasted discovering it 😛

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s