标签:contextmenu
代码如下:
TextView txtView = (TextView)findViewById(R.id.image);
registerForContextMenu(txtView);
txtView.setOnClickListener(new View.OnClickListener() {
@Override
void onClick(View v) {
// TODO Auto-generated method stub
v.showContextMenu();
}
});
重写方法:
@Override
public void registerForContextMenu(View view) {
// TODO Auto-generated method stub
super.registerForContextMenu(view);
view.setLongClickable(false);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
menu.add("1");
menu.add("2");
menu.add("3");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
return super.onContextItemSelected(item);
}
标签:contextmenu
原文地址:http://blog.csdn.net/sweiqin/article/details/44967529