Code example for MenuItem

Methods: getItemIdgetMenuInfo

0
	menu.add(0, MENU_OPEN_AUTHOR_PROFILE, 0, R.string.open_author_profile);
    } 
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo adapterContextMenuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
	CommentsData commentsData = (CommentsData) getListAdapter().getItem(adapterContextMenuInfo.position);
 
	switch (item.getItemId()) {
	    case MENU_OPEN_COMMENT_IN_BROWSER:
		startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getUrl())));
		break; 
	    case MENU_OPEN_AUTHOR_PROFILE:
		startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getAuthorUrl())));
		break; 
	} 
 
	return super.onContextItemSelected(item);
    } 
     
    @Override 
    public void onListItemClick(ListView list, View view, int position, long id) {
	CommentsData data = (CommentsData) getListAdapter().getItem(position);