Search in sources :

Example 1 with OnMenuItemClickListener

use of com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener in project ActionBarSherlock by JakeWharton.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main_menu, menu);
    // set up a listener for the refresh item
    final MenuItem refresh = (MenuItem) menu.findItem(R.id.menu_refresh);
    refresh.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        // on selecting show progress spinner for 1s
        public boolean onMenuItemClick(MenuItem item) {
            // item.setActionView(R.layout.progress_action);
            handler.postDelayed(new Runnable() {

                public void run() {
                    refresh.setActionView(null);
                }
            }, 1000);
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : OnMenuItemClickListener(com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 2 with OnMenuItemClickListener

use of com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener in project httpclient by pixmob.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main_menu, menu);
    // set up a listener for the refresh item
    final MenuItem refresh = (MenuItem) menu.findItem(R.id.menu_refresh);
    refresh.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        // on selecting show progress spinner for 1s
        public boolean onMenuItemClick(MenuItem item) {
            // item.setActionView(R.layout.progress_action);
            handler.postDelayed(new Runnable() {

                public void run() {
                    refresh.setActionView(null);
                }
            }, 1000);
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : OnMenuItemClickListener(com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener) MenuItem(com.actionbarsherlock.view.MenuItem)

Aggregations

MenuItem (com.actionbarsherlock.view.MenuItem)2 OnMenuItemClickListener (com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener)2