我正在使用XML文件为我的ListView创建上下文菜单.(请参阅下文).我还想为此上下文菜单设置标题.我阅读(http://www.mail-archive.com/android-developers@googlegroups.com/msg43062.html),我可以在onCreateContextMenu方法中使用menu.setHeaderTitle(myContextMenuTitle).但是我需要在XML文件中设置它.我怎么能做到这一点?
以下是onCreateContextMenu方法的代码,如果我做错了,请纠正我.这是我的context_menu.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/open" android:title="Open"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
这是我的onCreateContextMenu方法:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
super.onCreateContextMenu(menu, v, menuInfo);
}
Run Code Online (Sandbox Code Playgroud)
这是我的onCreate方法:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// extras = getIntent().getExtras();
registerForContextMenu(getListView());
...
}
Run Code Online (Sandbox Code Playgroud) 在选项卡页面上的用户控件上的上下文菜单中绑定命令时遇到问题.我第一次使用菜单(右键单击选项卡)它工作得很好,但如果我切换选项卡,命令将使用第一次使用的数据绑定实例.
如果我在usercontrol中放置一个绑定到该命令的按钮,它按预期工作...
有人可以告诉我,我做错了什么?
这是一个暴露问题的测试项目:
App.xaml.cs:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
CompanyViewModel model = new CompanyViewModel();
Window1 window = new Window1();
window.DataContext = model;
window.Show();
}
}
Run Code Online (Sandbox Code Playgroud)
Window1.xaml:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vw="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<DataTemplate x:Key="HeaderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type vw:PersonViewModel}">
<vw:UserControl1/>
</DataTemplate>
</Window.Resources>
<Grid>
<TabControl ItemsSource="{Binding Path=Persons}"
ItemTemplate="{StaticResource HeaderTemplate}"
IsSynchronizedWithCurrentItem="True" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
UserControl1.xaml:
<UserControl x:Class="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinWidth="200">
<UserControl.ContextMenu>
<ContextMenu > …Run Code Online (Sandbox Code Playgroud) <Button Name="btnFoo" Content="Foo" >
<Button.ContextMenu Placement="Bottom" PlacementTarget="btnFoo">
<MenuItem Header="Bar" />
</Button.ContextMenu>
</Button>
Run Code Online (Sandbox Code Playgroud)
给我一个运行时错误'UIElement'类型没有公共TypeConverter类
我也试过了
<Button Name="btnFoo" Content="Foo" >
<Button.ContextMenu Placement="Bottom" PlacementTarget="{Binding ElementName=btnFoo}">
<MenuItem Header="Bar" />
</Button.ContextMenu>
</Button>
Run Code Online (Sandbox Code Playgroud)
并将ContextMenu放在屏幕的左上角,而不是按钮
有一个弹出菜单附加到表单上的几个组件(按钮,但也有TCharts之类的东西),我想知道哪个组件被右键单击以首先启动弹出菜单.
click方法的Sender参数只指向TMenuItem,它是弹出菜单(或父级菜单项)的父级.
我如何获得原始组件?
这可能是一个简单的问题,但我一直在环顾四周,找不到答案.是否有任何代码可以从代码中显示Android上下文菜单,而不是按菜单按钮?例如,当我触摸屏幕时,它会调用上下文菜单吗?
当我在OleContainer(inplace)中编辑Word文档并切换到另一个Word文档然后切换回来时,我再也无法使用我的rightmouse按钮了.上下文菜单不会显示.
这发生在Word 2000上,而不是Word 2007上(我不知道其他版本).
我怎样才能摆脱这种行为?
如何重现:
OleContainer1.DestroyObject,以便您可以停止编辑编辑:我在以下系统上重现了上述行为(使用Citrix):
Windows Server 2003企业版
5.2版(Build 3790.srv03_sp2_rtm.070216-1710:Service Pack 2)
Microsoft Word 2000(9.0.6926 SP-3)
我使用Delphi 7(build 8.1)来创建应用程序.
我想写一个python脚本,它将上传我在Windows资源管理器中选择的任何文件.我们的想法是在Windows资源管理器中选择任何文件,右键单击以显示文件的上下文菜单,然后从那里选择一个命令......例如"上传到Web服务器".
选择该命令后,Python将运行一个脚本,该脚本接收文件路径和要上载的文件的文件名.编写将文件上传到web的Python脚本似乎很简单.目前还不清楚如何在Windows脚本菜单中为Python脚本创建实体.以及如何将文件路径和文件名传递给Python脚本来捕获....请指教!
我正在尝试使用带有图标和子菜单的python添加一些shell扩展,但我很难比pywin32中的演示更进一步.我似乎无法通过搜索谷歌找到任何东西.
我相信我需要注册一个com服务器,以便能够根据右键单击文件/文件夹的位置和文件类型等更改子菜单中的选项.
# A sample context menu handler.
# Adds a 'Hello from Python' menu entry to .py files. When clicked, a
# simple message box is displayed.
#
# To demostrate:
# * Execute this script to register the context menu.
# * Open Windows Explorer, and browse to a directory with a .py file.
# * Right-Click on a .py file - locate and click on 'Hello from Python' on
# the context menu.
import pythoncom
from win32com.shell …Run Code Online (Sandbox Code Playgroud) AG Chrome扩展程序可以进行" 浏览器操作 ".通常,当您单击它时,ext开发人员会显示选项,这意味着每个操作都需要2次点击,甚至是默认的99%的时间操作.Chrome本身添加了一个上下文菜单,其中包含以下几个选项:禁用ext,卸载ext,转到ext主页等.
我可以作为ext开发人员向该上下文菜单添加项目,这样我可以在正常/左/主鼠标单击下保持我的单击操作吗?
我知道chrome.contextMenus,但这仅适用于页面中的上下文菜单(请参阅属性' contexts ').
我在Chrome扩展程序开发指南中找不到它,但你知道的比我更多.
我有一段调用mousePressEvent的代码.我有左键单击输出光标的坐标,我有右键单击做同样的,但我也想右键单击打开上下文菜单.我到目前为止的代码是:
void plotspace::mousePressEvent(QMouseEvent*event)
{
double trange = _timeonright - _timeonleft;
int twidth = width();
double tinterval = trange/twidth;
int xclicked = event->x();
_xvaluecoordinate = _timeonleft+tinterval*xclicked;
double fmax = Data.plane(X,0).max();
double fmin = Data.plane(X,0).min();
double fmargin = (fmax-fmin)/40;
int fheight = height();
double finterval = ((fmax-fmin)+4*fmargin)/fheight;
int yclicked = event->y();
_yvaluecoordinate = (fmax+fmargin)-finterval*yclicked;
cout<<"Time(s): "<<_xvaluecoordinate<<endl;
cout<<"Flux: "<<_yvaluecoordinate<<endl;
cout << "timeonleft= " << _timeonleft << "\n";
returncoordinates();
emit updateCoordinates();
if (event->button()==Qt::RightButton)
{
contextmenu->setContextMenuPolicy(Qt::CustomContextMenu);
connect(contextmenu, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowContextMenu(const QPoint&)));
void A::ShowContextMenu(const QPoint …Run Code Online (Sandbox Code Playgroud) contextmenu ×10
android ×2
delphi ×2
python ×2
wpf ×2
automation ×1
button ×1
c++ ×1
code-behind ×1
data-binding ×1
events ×1
ms-word ×1
mvvm ×1
ole ×1
pywin32 ×1
qt ×1
show ×1
windows ×1
xaml ×1