本篇文章给大家谈谈Delphi菜单的应用,以及系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态的知识点,同时本文还将给你拓展android–如何创建弹出菜单作为另一个弹出
本篇文章给大家谈谈Delphi 菜单的应用,以及系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态的知识点,同时本文还将给你拓展android – 如何创建弹出菜单作为另一个弹出菜单菜单项的子菜单、android-溢出菜单和子菜单中的色调菜单图标、Angular-UI + D3:如何实现上下文菜单(弹出菜单与模式菜单)?、c – 在Qt应用程序菜单栏的主菜单中添加和本地化菜单项等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:- Delphi 菜单的应用(系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态)
- android – 如何创建弹出菜单作为另一个弹出菜单菜单项的子菜单
- android-溢出菜单和子菜单中的色调菜单图标
- Angular-UI + D3:如何实现上下文菜单(弹出菜单与模式菜单)?
- c – 在Qt应用程序菜单栏的主菜单中添加和本地化菜单项
Delphi 菜单的应用(系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态)
总结
以上是小编为你收集整理的Delphi 菜单的应用(系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态)全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
android – 如何创建弹出菜单作为另一个弹出菜单菜单项的子菜单
提前谢谢
解决方法
您可以使用列表视图或任何其他复合列表视图:
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:orientation="vertical" > <ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout>
第2步:listviewchild.xml
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginLeft="15dp" android:layout_toRightOf="@+id/textview_name" android:src="@drawable/ic_launcher" />
第3步:
String popUpContents[]; PopupWindow popupWindowDogs; ListView listView1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView1=(ListView)findViewById(R.id.listView1); listView1.setAdapter(new MyAddapter(MainActivity.this)); // binding the list view. /* * initialize pop up window items list */ // add items on the array dynamically // format is Company Name:: ID List<String> dogsList = new ArrayList<String>(); dogsList.add("Samsung"); dogsList.add("Google"); dogsList.add("Yahoo"); dogsList.add("Microsoft"); // convert to simple array popUpContents = new String[dogsList.size()]; dogsList.toArray(popUpContents); /* * initialize pop up window */ popupWindowDogs = popupWindowDogs(); } /* * */ public PopupWindow popupWindowDogs() { // initialize a pop up window type PopupWindow popupWindow = new PopupWindow(this); // the drop down list is a list view ListView listViewDogs = new ListView(this); // set our adapter and pass our pop up window contents listViewDogs.setAdapter(dogsAdapter(popUpContents)); // set the item click listener listViewDogs.setonItemClickListener(new DogsDropdownOnItemClickListener()); // some other visual settings popupWindow.setFocusable(true); popupWindow.setWidth(250); popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); // set the list view as pop up window content popupWindow.setContentView(listViewDogs); return popupWindow; } /* * adapter where the list values will be set */ private ArrayAdapter<String> dogsAdapter(String dogsArray[]) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,dogsArray) { @Override public View getView(int position,View convertView,ViewGroup parent) { // setting the ID and text for every items in the list String text = getItem(position); // visual settings for the list item TextView listItem = new TextView(MainActivity.this); listItem.setText(text); listItem.setTag(position); listItem.setTextSize(22); listItem.setPadding(10,10,10); listItem.setTextColor(Color.WHITE); return listItem; } }; return adapter; }
}
第4步:
Context rContext; private LayoutInflater rInflater; private Activity activity; public MyAddapter(Context c) { rInflater = LayoutInflater.from(c); rContext = c; } public MyAddapter(Activity imagebinding) { // Todo Auto-generated constructor stub activity = imagebinding; rContext = imagebinding; rInflater = LayoutInflater.from(imagebinding); rContext = imagebinding; rInflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { // Todo Auto-generated method stub return 10; } @Override public Object getItem(int arg0) { // Todo Auto-generated method stub return null; } @Override public long getItemId(int position) { // Todo Auto-generated method stub return 0; } @Override public View getView(final int position,ViewGroup parent) { // Todo Auto-generated method stub convertView = rInflater.inflate(R.layout.child,null); final MyDat mydat = new MyDat(); mydat.imageView1=(ImageView)convertView.findViewById(R.id.imageView1); mydat.imageView1.setonClickListener(new OnClickListener() { @Override public void onClick(View v) { // Todo Auto-generated method stub popupWindowDogs.showAsDropDown(v,-5,0); } }); return convertView; } class MyDat { ImageView imageView1; }
第5步:
@Override public void onItemClick(AdapterView<?> arg0,View v,int arg2,long arg3) { // get the context and main activity to access variables Context mContext = v.getContext(); MainActivity mainActivity = ((MainActivity) mContext); // add some animation when a list item was clicked Animation fadeInAnimation = AnimationUtils.loadAnimation(v.getContext(),android.R.anim.fade_in); fadeInAnimation.setDuration(10); v.startAnimation(fadeInAnimation); // dismiss the pop up mainActivity.popupWindowDogs.dismiss(); // get the text and set it as the button text Toast.makeText(mContext,"Selected Positon is: " + arg2,100).show(); }
android-溢出菜单和子菜单中的色调菜单图标
我设法在工具栏的溢出菜单和子菜单中显示图标,但找不到如何根据图标的位置对其进行着色的方法.这是我正在使用的代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main, menu);
// Show icons in overflow menu
if (menu instanceof MenuBuilder) {
MenuBuilder m = (MenuBuilder) menu;
m.setoptionalIconsVisible(true);
}
// Change icons color
changeIconsColor(menu, colornormal, colorInMenu, false);
return super.onCreateOptionsMenu(menu);
}
public static void changeIconsColor(Menu menu, int colornormal, int colorInMenu, boolean isInSubMenu) {
// Change icons color
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
Drawable icon = item.getIcon();
if (icon != null) {
int color = (((MenuItemImpl) item).requiresActionButton() ? colornormal : colorInMenu);
icon.setColorFilter(color, PorterDuff.Mode.SRC_IN);
icon.setAlpha(item.isEnabled() ? 255 : 128);
}
if (item.hasSubMenu()) {
changeIconsColor(item.getSubMenu(), colornormal, colorInMenu, true);
}
}
}
使用MenuItem.requiresActionButton()可以知道某个项目在XML的showAsAction属性中是否具有从不或始终具有值,但不知道其是否具有ifRoom值.因此,如果我想要适当的着色,则不能在项目中使用ifRoom值,这是非常严格的.
>是否有一种方法可以在所有情况下正确着色菜单项?
>更重要的是,是否有一种内置的方法可以为主题或样式着色项,从而使我不必使用此复杂代码?即使解决方案不包含溢出菜单中的图标,我也想知道.
如果没有其他方法,我会很好地使用反射.
解决方法:
不幸的是,无法使用主题或样式来设置菜单项图标颜色的色调.您需要一种方法来检查MenuItem在ActionBar或溢出菜单中是否可见.本机和支持MenuItemImpl类都具有用于此目的的方法,但它们仅限于库或隐藏.这需要反思.您可以使用以下方法检查菜单项是否可见,然后设置滤色器:
public static boolean isActionButton(@NonNull MenuItem item) {
if (item instanceof MenuItemImpl) {
return ((MenuItemImpl) item).isActionButton();
} else {
// Not using the support library. This is a native MenuItem. Reflection is needed.
try {
Method m = item.getClass().getDeclaredMethod("isActionButton");
if (!m.isAccessible()) m.setAccessible(true);
return (boolean) m.invoke(item);
} catch (Exception e) {
return false;
}
}
}
您还需要等到菜单膨胀后再对项目进行着色.为此,您可以获取对ActionBar的引用,并在绘制ActionBar之后给MenuItem着色.
例:
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
int id = getResources().getIdentifier("action_bar", "id", "android");
ViewGroup actionBar;
if (id != 0) {
actionBar = (ViewGroup) findViewById(id);
} else {
// You must be using a custom Toolbar. Use the toolbar view instead.
// actionBar = yourToolbar
}
actionBar.post(new Runnable() {
@Override public void run() {
// Add code to tint menu items here
}
});
return super.onCreateOptionsMenu(menu);
}
这是我编写的帮助为菜单项图标着色的课程:https://gist.github.com/jaredrummler/7816b13fcd5fe1ac61cb0173a1878d4f
Angular-UI + D3:如何实现上下文菜单(弹出菜单与模式菜单)?
如何解决Angular-UI + D3:如何实现上下文菜单(弹出菜单与模式菜单)??
可以在由生成的代码中添加指令d3
,只需确保$compile
在呈现内容后调用服务即可。
对于给定的示例,它看起来像这样:
.directive(''barChart'', function($compile){ // inject $compile
var chart = d3.custom.barChart();
return {
restrict: ''E'',
replace: true,
template: ''<div></div>'',
scope:{
height: ''=height'',
data: ''=data'',
hovered: ''&hovered''
},
link: function(scope, element, attrs) {
var chartEl = d3.select(element[0]);
chart.on(''customHover'', function(d, i){
scope.hovered({args:d});
});
scope.$watch(''data'', function (newVal, oldVal) {
chartEl.datum(newVal).call(chart);
$compile(element.contents())(scope); // <-- call to $compile
});
scope.$watch(''height'', function(d, i){
chartEl.call(chart.height(scope.height));
$compile(element.contents())(scope); // <-- call to $compile
})
}
}
并在d3
的绘图功能中:
bars.enter().append(''rect'')
.classed(''bar'', true)
.attr(''myPopover'', ''Text to show'') // <-- Adding an attribute here.
.attr({x: chartW,
width: barW,
y: function(d, i) { return y1(d); },
height: function(d, i) { return chartH - y1(d); }
})
.on(''mouSEOver'', dispatch.customHover);
Demo
解决方法
给定以下用例:
我使用D3js渲染由AngularJS管理的对象。我想向D3图表添加交互性。当单击svg元素时,我希望有一种弹出菜单允许修改对象属性。这些属性是AngularJS必需的,但不是D3呈现的。
D3-Angular集成源自使用闭包的http://bl.ocks.org/biovisualize/5372077。
当前实施:
从今天开始,我正在使用angular-ui引导程序中的$
modal服务创建弹出菜单。从功能角度来看,它工作得很好:当单击svg元素时,D3调度一个事件该事件被Angular捕获,该事件调用$
modal服务在模式窗口中,我修改了对象属性
但是我对渲染不满意。我希望弹出菜单看起来像一个弹出框。应将其放置在靠近单击的svg元素附近。
据我了解,我有 两种选择 :
- 继续使用$ modal服务并修改其外观。应该采取什么方法?使用windowClass选项?
- 停止使用$ modal服务,并开始研究popover指令。问题是我认为不可能将这样的指令添加到svg元素中。解决方案是在$ modal服务附近创建一个popover服务。
应该选择哪个选项?以及如何实施?
编辑:
使用自定义的my-popover指令工作的监听器:http
://plnkr.co/edit/5KYvxi?p=preview
c – 在Qt应用程序菜单栏的主菜单中添加和本地化菜单项
[]
如您所见,主菜单中的所有菜单项(通过主菜单,我的意思是名称为应用程序名称的菜单项,如此处为Evernote)均使用法语进行本地化. Evernote应用程序本身带来了许多菜单项,例如ÉvaluezEvernotepour Mac(适用于Mac的费率Evernote),information du compte …(帐户信息…)等.另外还有标准的OS X提供的菜单Quit Evernote,Preferences等物品也是本地化的.
我的问题:
>如何在此主菜单中添加新项目?如何访问此菜单添加项目?
>我如何根据我的应用本地化来本地化这些项目,OS X提供的默认项目和我添加的项目?
>在Evernote菜单中,除了“服务”菜单选项外,所有内容似乎都已本地化(但子菜单选项已本地化!)?这不能也是本地化的吗?
我尝试过的:
fMenuBar = fMainWindow->menuBar(); fMenuFile = fMenuBar->addMenu(QObject::tr(qPrintable(String_Class::FileMenu))); //"File" in English,translated into other languages fAboutAppAct = new QAction(QObject::tr(qPrintable(String_Class::About_App)),fMainWindow); //prints "About App",localized in all languages fMenuFile->addAction(fAboutAppAct); fAboutAppAct->setMenuRole(QAction::AboutRole); //otherwise it sits with the other file menu options in the File menu //reset UI language slot,called whenver UI language is reset. It retranslates all strings in all menus,except this void AppMenu::reTranslateUISlot() { fAboutAppAct->setText(QObject::tr(qPrintable(String_Class::About_App))); }
解决方法
void MainWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { this->retranslateUi(this); quickStart->retranslateUi(quickStart); //etc... } else { QMainWindow::changeEvent(event); } }
您可以强制Widgets重新翻译自己.但是你需要先注册一些QTranslator.
例如,在MainWindow的构造函数中(或在某些配置对话框中),如果可以在运行时更改语言(我在软件中完成的操作):
CustomizeOptionsDialog::CustomizeOptionsDialog(QWidget *parent) : QDialog(parent,Qt::Tool) { // Load the language of the application customTranslator.load(languages.value( SettingsPrivate::instance()->language()) ); // Translate standard buttons (OK,Cancel,...) defaultQtTranslator.load("qt_" + SettingsPrivate::instance()->language(),QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QApplication::installTranslator(&customTranslator); QApplication::installTranslator(&defaultQtTranslator); }
其中language()返回“fr”,“gb”或“cs”(从选项中选择新语言时发出的信号初始化).
/** Change language at runtime. */ void CustomizeOptionsDialog::changeLanguage(const QString &language) { QString lang = languages.value(language); SettingsPrivate *settings = SettingsPrivate::instance(); // If the language is successfully loaded,tells every widget that they need to be redisplayed if (!lang.isEmpty() && lang != settings->language() && customTranslator.load(lang)) { settings->setLanguage(language); defaultQtTranslator.load("qt_" + lang,QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QApplication::installTranslator(&customTranslator); /// Todo: reload plugin UI QApplication::installTranslator(&defaultQtTranslator); } else { labelStatusLanguage->setText(tr("No translation is available for this language :(")); } }
我希望它有所帮助.
今天关于Delphi 菜单的应用和系统菜单添加一项、主菜单增加历史记录、弹出菜单的动态合并、菜单中画图、显示状态的讲解已经结束,谢谢您的阅读,如果想了解更多关于android – 如何创建弹出菜单作为另一个弹出菜单菜单项的子菜单、android-溢出菜单和子菜单中的色调菜单图标、Angular-UI + D3:如何实现上下文菜单(弹出菜单与模式菜单)?、c – 在Qt应用程序菜单栏的主菜单中添加和本地化菜单项的相关知识,请在本站搜索。
本文标签: