本文整理汇总了Java中android.view.ContextMenu.setHeaderIcon方法的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu.setHeaderIcon方法的具体用法?Java ContextMenu.setHeaderIcon怎么用?Java ContextMenu.setHeaderIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.setHeaderIcon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
final SipProfile account = profileFromContextMenuInfo(menuInfo);
if(account == null) {
return;
}
WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);
// Setup the menu header
menu.setHeaderTitle(account.display_name);
if(wizardInfos != null) {
menu.setHeaderIcon(wizardInfos.icon);
}
menu.add(0, MENU_ITEM_ACTIVATE, 0, account.active ? R.string.deactivate_account
: R.string.activate_account);
menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);
}
示例2: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
KRFAM.log("MainActivity.java > onCreateContextMenu");
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Account contextAccount = ACCOUNT_LIST_DATA.get(info.position);
if (contextAccount.isFolder) {
menu.setHeaderTitle(contextAccount.name);
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.menu_context_folder, menu);
menu.setHeaderIcon(R.drawable.ic_folder_black_24dp);
} else {
menu.setHeaderTitle(contextAccount.name);
super.onCreateContextMenu(menu, v, menuInfo);
if (contextAccount.locked) {
getMenuInflater().inflate(R.menu.menu_context_account_locked, menu);
menu.setHeaderIcon(R.drawable.ic_lock_outline_black_24dp);
} else {
getMenuInflater().inflate(R.menu.menu_context_account, menu);
}
}
}
示例3: setHeaderIcon
import android.view.ContextMenu; //导入方法依赖的package包/类
private void setHeaderIcon(ContextMenu menu, Drawable icon) {
int width = getHeaderIconWidth();
if (icon.getMinimumWidth() <= width) {
menu.setHeaderIcon(icon);
} else if (icon instanceof BitmapDrawable) {
Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) icon).getBitmap(), width, width, false);
menu.setHeaderIcon(new BitmapDrawable(getResources(), bitmap));
}
}