Java Code Examples for android.support.v7.app.ActionBar.getCustomView()

The following are Jave code examples for showing how to use getCustomView() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: QueryHighlighter   File: MainActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mAdapter = new CheesesAdapter();

    final ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(mAdapter);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setCustomView(R.layout.search_view);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    final EditText editText = (EditText) actionBar.getCustomView();
    editText.addTextChangedListener(mTextWatcher);
    editText.requestFocus();
}