本文整理匯總了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));
}
}