當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextMenu.size方法代碼示例

本文整理匯總了Java中android.view.ContextMenu.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextMenu.size方法的具體用法?Java ContextMenu.size怎麽用?Java ContextMenu.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ContextMenu的用法示例。


在下文中一共展示了ContextMenu.size方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle(R.string.accounts_context_menu_title);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    BaseAccount account =  mAdapter.getItem(info.position);

    if ((account instanceof Account) && !((Account) account).isEnabled()) {
        getMenuInflater().inflate(R.menu.disabled_accounts_context, menu);
    } else {
        getMenuInflater().inflate(R.menu.accounts_context, menu);
    }

    if (account instanceof SearchAccount) {
        for (int i = 0; i < menu.size(); i++) {
            android.view.MenuItem item = menu.getItem(i);
                item.setVisible(false);
        }
    }
    else {
        EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
        if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
            menu.findItem(R.id.move_up).setEnabled(false);
        }
        else {
            menu.findItem(R.id.move_up).setEnabled(true);
        }
        if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
            menu.findItem(R.id.move_down).setEnabled(false);
        }
        else {
            menu.findItem(R.id.move_down).setEnabled(true);
        }
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:37,代碼來源:Accounts.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: removeUnsupportedItems

import android.view.ContextMenu; //導入方法依賴的package包/類
private void removeUnsupportedItems(ContextMenu menu, int[] whitelist) {
    Arrays.sort(BASE_WHITELIST);
    Arrays.sort(whitelist);
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (Arrays.binarySearch(whitelist, item.getItemId()) < 0
                && Arrays.binarySearch(BASE_WHITELIST, item.getItemId()) < 0) {
            menu.removeItem(item.getItemId());
            i--;
        }
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:13,代碼來源:ChromeContextMenuPopulator.java

示例5: onCreateContextMenu

import android.view.ContextMenu; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    MenuInflater inflater = new MenuInflater(itemView.getContext());
    inflater.inflate(R.menu.menu_log_item_context, menu);
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
}
 
開發者ID:DorianScholz,項目名稱:OpenLibre,代碼行數:9,代碼來源:LogRecyclerViewAdapter.java

示例6: onCreateContextMenu

import android.view.ContextMenu; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    BreventActivity activity = (BreventActivity) mFragment.getActivity();
    menu.setHeaderTitle(label);
    menu.add(Menu.NONE, R.string.context_menu_select, Menu.NONE,
            activity.getString(R.string.context_menu_select));
    menu.add(Menu.NONE, R.string.context_menu_package_name, Menu.NONE,
            activity.getString(R.string.context_menu_package_name));
    menu.add(Menu.NONE, R.string.context_menu_app_info, Menu.NONE,
            activity.getString(R.string.context_menu_app_info));
    PackageManager packageManager = mFragment.getActivity().getPackageManager();
    if (BuildConfig.APPLICATION_ID.equals(packageName)) {
        menu.add(Menu.NONE, R.string.context_menu_brevent_server_info, Menu.NONE,
                activity.getString(R.string.context_menu_brevent_server_info));
    } else if (packageManager.getLaunchIntentForPackage(packageName) != null) {
        menu.add(Menu.NONE, R.string.context_menu_open, Menu.NONE,
                activity.getString(R.string.context_menu_open));
    }
    if (activity.isBrevent(packageName)) {
        if (activity.isPriority(packageName)) {
            menu.add(Menu.NONE, R.string.context_menu_unset_priority, Menu.NONE,
                    activity.getString(R.string.context_menu_unset_priority));
        } else {
            menu.add(Menu.NONE, R.string.context_menu_set_priority, Menu.NONE,
                    activity.getString(R.string.context_menu_set_priority));
        }
    }
    if (activity.hasOps(packageName)) {
        menu.add(Menu.NONE, R.string.context_menu_appops, Menu.NONE,
                activity.getString(R.string.context_menu_appops));
    }
    int size = menu.size();
    for (int i = 0; i < size; ++i) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
    String important = activity.getLabel("", packageName);
    if (!TextUtils.isEmpty(important)) {
        menu.add(AppsLabelLoader.trim(important));
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:41,代碼來源:AppsItemViewHolder.java

示例7: 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.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。