This is how you get it if you are using Support Lib v7 (aka ActionBarActivity) - Android User Interface

Android examples for User Interface:ActionBar

Description

This is how you get it if you are using Support Lib v7 (aka ActionBarActivity)

Demo Code


import android.annotation.TargetApi;
import android.content.Context;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView;
import android.view.MenuItem;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.TextView;

public class Main{
    /**//from   w  w w.j  ava2 s .  com
     * This is how you get it if you are using Support Lib v7 (aka ActionBarActivity)
     */
    public static AutoCompleteTextView GetSupportV7ActionBarSeachEditText(
            MenuItem item) {
        AutoCompleteTextView editText;
        SearchView sv = (SearchView) MenuItemCompat.getActionView(item);
        editText = (AutoCompleteTextView) sv
                .findViewById(R.id.search_src_text);
        return editText;
    }
}

Related Tutorials