当前位置: 首页>>代码示例>>Java>>正文


Java ContextMenu.clear方法代码示例

本文整理汇总了Java中android.view.ContextMenu.clear方法的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu.clear方法的具体用法?Java ContextMenu.clear怎么用?Java ContextMenu.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ContextMenu的用法示例。


在下文中一共展示了ContextMenu.clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    //clear menu
    if (menu.size() != 0) {
        menu.clear();
    }

    int id_view = v.getId();

    switch (id_view) {
        case R.id.arrow:
            List<Subject> subjects = getSubjectList();
            if (subjects.size() == 0) {
                FunctionHelper.makeSToast(mContext, mResources.getString(R.string.no_data_available));
            } else {
                for (Subject s : subjects) {
                    //Add menu item with groupId
                    menu.add(ID_GROUP_SUBJECT, s.getSubject_id(), s.getSubject_id(), s.getSubject_name());
                }
                menu.setHeaderTitle(R.string.choose_a_subject);
            }
            break;
    }
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:26,代码来源:WeekLessonDetailActivity.java

示例2: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (!canCreateContextMenu(menu, menuInfo)) {
        return;
    }
    menu.clear();
    ViewHolder holder = (ViewHolder) ((AdapterContextMenuInfo) menuInfo).targetView.getTag();
    menu.setHeaderTitle(holder.nameView.getText());
    if (holder.icon != null) {
        setHeaderIcon(menu, holder.icon);
    }
    menu.add(Menu.NONE, R.string.app_info, Menu.NONE, R.string.app_info);
    updatePreventMenu(menu, holder.packageName);
    if (getMainIntent(holder.packageName) != null) {
        menu.add(Menu.NONE, R.string.open, Menu.NONE, R.string.open);
    }
    if (holder.canUninstall) {
        menu.add(Menu.NONE, R.string.uninstall, Menu.NONE, R.string.uninstall);
    }
    if (appNotification) {
        menu.add(Menu.NONE, R.string.app_notifications, Menu.NONE, R.string.app_notifications);
    }
}
 
开发者ID:brevent,项目名称:prevent,代码行数:24,代码来源:PreventFragment.java

示例3: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    //clear menu
    if (menu.size() != 0) {
        menu.clear();
    }

    int id_view = v.getId();

    switch (id_view) {
        case R.id.arrow:
            try {
                mTeacherList = mDbHelper.getTeacherList();
            } catch (NullObjectException e) {
                Log.d(TAG, e.toString());
            }

            if (mTeacherList == null || mTeacherList.size() == 0) {
                FunctionHelper.makeSToast(mContext, mResources.getString(R.string.no_data_available));
            } else {
                for (Teacher t : mTeacherList) {
                    //Add menu item with groupId
                    menu.add(ID_GROUP_TEACHER, t.getTeacher_id(), t.getTeacher_id(), t.getTeacher_name());
                }
                menu.setHeaderTitle(R.string.choose_a_teacher);
            }
            break;
    }
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:31,代码来源:AddEditDetailSubjectActivity.java

示例4: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	menu.clear();
	
	menu.add(0, MENU_EDIT, 0, R.string.menu_edit);
	menu.add(0, MENU_PAUSE, 0, R.string.menu_pause);
	menu.add(0, MENU_DELETE, 0, R.string.menu_delete);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:9,代码来源:BarrageList.java

示例5: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            String name = item.getTitle().toString();
            mEtLocation.setText(name);
            return true;
        }
    };
    //clear menu
    if (menu.size() != 0) {
        menu.clear();
    }

    int id_view = v.getId();

    switch (id_view) {
        case R.id.arrow:
            try {
                mLocationList = mDbHelper.getLocationList();
            } catch (NullObjectException e) {
                Log.d(TAG, e.toString());
            }

            if (mLocationList == null || mLocationList.size() == 0) {
                FunctionHelper.makeSToast(mActivity, mResources.getString(R.string.no_data_available));
            } else {
                int i = 0;
                for (Location l : mLocationList) {
                    //Add menu item with groupId
                    menu.add(ID_GROUP_LOCATION, l.getLocation_id(), l.getLocation_id(), l.getLocation_name());

                    menu.getItem(i).setOnMenuItemClickListener(listener);
                    i++;
                }
                menu.setHeaderTitle(R.string.choose_a_location);
            }
            break;
    }


}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:46,代码来源:AddEditWeekLessonDialogFragment.java


注:本文中的android.view.ContextMenu.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。