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

The following examples show how to use android.support.v7.app.ActionBar#getCustomView() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: QueryHighlighter   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 2
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.homescreen_fragment, container, false);

    ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
    actionBarCustomView = actionBar.getCustomView();

    gridview = (GridView) rootView.findViewById(R.id.gridview);
    phoneBackgroundImage = (ImageView) rootView.findViewById(R.id.phone_homescreen_background);

    fabMenu = (FloatingActionsMenu) rootView.findViewById(R.id.floating_action_menu);
    fabAddNew = (PlusFloatingActionButton) rootView.findViewById(R.id.fab_add_new_cell);
    fabBookmark = (FloatingActionButton) rootView.findViewById(R.id.fab_bookmark);
    fabEditFeeds = (FloatingActionButton) rootView.findViewById(R.id.fab_edit_feeds);
    return rootView;
}
 
Example 3
public static void setProgressSpinnerVisible(AppCompatActivity activity, boolean visible) {
    ActionBar bar = activity.getSupportActionBar();

    if (bar.getCustomView() == null) {
        ProgressBar spinner = new ProgressBar(activity);
        spinner.setIndeterminate(true);
        bar.setCustomView(spinner);
    }

    bar.setDisplayShowCustomEnabled(visible);
}