Example usage for android.view MenuItem setActionView

List of usage examples for android.view MenuItem setActionView

Introduction

In this page you can find the example usage for android.view MenuItem setActionView.

Prototype

public MenuItem setActionView(@LayoutRes int resId);

Source Link

Document

Set an action view for this menu item.

Usage

From source file:com.example.ward.view.CursorFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);
}

From source file:org.strongswan.android.ui.TrustedCertificateListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(R.string.search);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);
}

From source file:com.example.android.network.sync.basicsyncadapter.EntryListFragment.java

/**
 * Set the state of the Refresh button. If a sync is active, turn on the ProgressBar widget.
 * Otherwise, turn it off./*from w  ww  .  j ava  2  s  .  com*/
 *
 * @param refreshing True if an active sync is occurring, false otherwise
 */
public void setRefreshActionButtonState(boolean refreshing) {
    if (mOptionsMenu == null) {
        return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
        }
    }
}

From source file:com.election.US.basicsyncadapter.EntryListFragment.java

/**
 * Set the state of the Refresh button. If a sync is active, turn on the ProgressBar widget.
 * Otherwise, turn it off.//  ww w. j  a  v  a  2s . c  o m
 *
 * @param refreshing True if an active sync is occuring, false otherwise
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setRefreshActionButtonState(boolean refreshing) {
    if (mOptionsMenu == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
        }
    }
}

From source file:org.strongswan.android.ui.SelectedApplicationsListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(R.string.search);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.java

private void animateMenuItem(final MenuItem vEditSubkeys, final boolean animateShow) {

    View actionView = LayoutInflater.from(this).inflate(R.layout.edit_icon, null);
    vEditSubkeys.setActionView(actionView);
    actionView.setTranslationX(animateShow ? 150 : 0);

    ViewPropertyAnimator animator = actionView.animate();
    animator.translationX(animateShow ? 0 : 150);
    animator.setDuration(300);/*  w  w w.j a  v  a  2  s  .com*/
    animator.setInterpolator(new OvershootInterpolator(1.5f));
    animator.setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!animateShow) {
                vEditSubkeys.setVisible(false);
            }
            vEditSubkeys.setActionView(null);
        }
    });
    animator.start();

}

From source file:com.dogar.geodesic.activities.MainActivity.java

private void setRefreshActionButtonState(boolean refreshing) {
    if (mOptionsMenu == null) {
        return;//from  w  w  w  .ja  v a2s. co  m
    }
    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
            setGMFragment();
        }
    }
}

From source file:fr.cph.chicago.activity.BusActivity.java

@Override
public final boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from   www.  j a  v a  2s .co m
        // overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
        return true;
    case R.id.action_refresh:

        // Load top bar animation
        MenuItem menuItem = item;
        menuItem.setActionView(R.layout.progressbar);
        menuItem.expandActionView();

        // Load data
        new LoadData().execute();
        return true;
    }
    return super.onOptionsItemSelected(item);

}

From source file:com.meiste.tempalarm.ui.CurrentTemp.java

/**
 * Set the state of the Refresh button. If a sync is active, turn on the ProgressBar widget.
 * Otherwise, turn it off.//from   ww  w .j  av a  2  s  .c o m
 *
 * @param refreshing True if an active sync is occurring, false otherwise
 */
public void setRefreshActionButtonState(final boolean refreshing) {
    if (mOptionsMenu == null) {
        return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.action_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
        }
    }
}

From source file:nyc.c4q.jordansmith.finefree.ActivityMain.java

private void setupCarMenu() {
    for (int i = 0; i < cars.size(); i++) {
        submenu.clear();//from  w w w.ja v a 2 s  .  c om
        submenu.add(cars.get(i).getName()).setTitle(cars.get(i).getName().toString())
                .setIcon(R.drawable.ic_car_black_36dp);

        final MenuItem item = submenu.getItem(i);
        Button button = new Button(this);
        button.setText("Remove");
        button.setTextColor(ContextCompat.getColor(this, R.color.white));
        item.setActionView(button);
        button.setBackground(getDrawable(R.drawable.button_shape));
        item.getActionView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(ActivityMain.this).setIcon(android.R.drawable.ic_dialog_alert)
                        .setTitle("Delete Car").setMessage("Are you sure you want to remove car?")
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                System.out.println("CLICKED " + item.getTitle());
                                cupboard().withDatabase(db).delete(Car.class, "name = ?",
                                        (String) item.getTitle());

                                updateSubmenu();
                            }
                        }).setNegativeButton("Cancel", null).show();

            }
        });

    }
}