- 浏览: 47763 次
- 性别:
- 来自: 西安
-
最新评论
Working with Context Menus
Android supports the idea of context menus through an action called a long click.
context menu is represented as a ContextMenu class in the
Android menu architecture. a context menu is owned by a view, the method to populate context menus resides in the Activity class. This method is called activity.onCreateContextMenu(),
and its role resembles that of the activity.onCreateOptionsMenu() method.
If you want a particular view
to own a context menu, you must register that view with its activity specifically for the
purpose of owning a context menu. You do this through the
activity.registerForContextMenu(view) method,
the steps to implement a context menu:
1. Register a view for a context menu in an activity’s onCreate() method.
2. Populate the context menu using onCreateContextMenu(). You must
complete step 1 before this callback method is invoked by Android.
3. Respond to context-menu clicks.
A first step
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)this.findViewById(R.id.textViewId);
registerForContextMenu(this.getTextView());
}
B:Populating a Context Menu
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
menu.setHeaderTitle("Sample Context Menu");
menu.add(200, 200, 200, "item1");
}
C:Responding to Context Menu Items
@Override
public boolean onContextItemSelected(MenuItem item)
{
if (item.itemId() = some-menu-item-id)
{
//handle this menu item
return true;
}
}
发表评论
-
Android Intent and Intent Filter (转)
2011-03-10 22:47 1462Android Intent and Intent ... -
Intent详解
2011-03-03 14:18 1143在应用中,我们可以以两种形式来使用Intent: 直接I ... -
Intent间传送数据一般有两种常用方法
2011-01-24 14:50 1310Intent间传送数据一般有两种常用的办法: 1.extra ... -
android RelativeLayout 详解
2011-01-01 09:46 1584<?xml version="1.0" ... -
How to Use Android Downloads Provider
2010-12-20 21:41 1332本文转载自 http://blog.lytsing.or ... -
android 开发中的一些小知识点
2010-12-17 09:49 10021 关于onPause(): onPause ... -
content provider 深入解析
2010-12-15 22:04 1099Content providers are on ... -
Service的高级应用
2010-12-12 20:48 1359下面是android Service的高级应用的一个例子,主要 ... -
TabActivity
2010-12-12 19:09 1773下面是一个使用android tabactivity 的例子 ... -
android 测试初探(android test)
2010-12-07 15:00 8016android Testing and Instrumenta ... -
Localization of android
2010-12-05 21:51 0android 会在不同地域的不同机器上运行。为了是应用能够 ... -
android高效编程之使用本地变量
2010-12-05 14:26 977hava a look at the following co ... -
在不同的Activity中传递对象的方法
2010-12-02 10:20 2014下面我们将要实现的功 ... -
Cursor与Adapter
2010-11-21 08:34 1229来自: http://hi.baidu.com/lfcaoli ... -
Handler的理解
2010-11-14 20:58 840A Handler allows you to sen ... -
android开发问题解决日志
2010-11-14 18:33 18841.、android中R文件消失的处理方式 ... -
android 中对SDCard 的操作
2010-11-11 14:14 1639对于像视频这样的大文件,我们可以把它存放在SDCard。 SD ... -
ViewAnimation
2010-11-05 12:46 1043view animation 的实现 Understandi ... -
android高效的编写高效代码
2010-10-17 19:13 788本文来源于: 从此学习网 原文: http://www.con ... -
scale animation
2010-10-11 23:29 1613Scale animation: You use this t ...
相关推荐
Working with Worksheets and Ranges Section 9.1. Work with Worksheet Objects Section 9.2. Worksheets and Worksheet Members Section 9.3. Sheets Members Section 9.4. Work with Outlines Section...
#### Chapter 4: Working with Widgets Widgets are a core component of GWT applications. This chapter examines standard GWT widgets, providing insights into their use within the context of the Dashboard...
Menus in Context Taking a Peek Yet More Inflation Menu XML Structure Menu Options and XML Inflating the Menu ■Chapter 12: Fonts Love the One You’re With More Fonts Here a Glyph, There a Glyph ...
- **Advanced Plug-in Development**: Advanced topics related to plug-in development, including working with preferences, commands, and editors. **Appendices** - **Appendix A: Java Perspective Menu ...
[context menus] fix of getting focus back, see : https://sciter.com/forums/topic/input/ [win] Fix of crash on ALT+ENTER . [win] fix of "D3DGear bug" – crash when D3DGear is running. cr/lf handling ...
Working with Unicode in UltraEdit/UEStudio In this tutorial, we'll cover some of the basics of Unicode-encoded text and Unicode files, and how to view and manipulate it in UltraEdit. Search and delete...
o Fixed bug from version 2.08: Some filters stopped working... * Version 2.08: o Added support for filtering by process ID (In Advanced Filters window), for example: include:process:327 * ...
please read the document "upgrading_to_v4.txt" before you begin working on your existing projects. Note about "Property does not exist" errors: Since all demos were developed with the latest ...
owner-draw menus and much more. 2. The editors of standard properties with some advanced features. TPicture and TGraphic editor adds Copy and Paste Buttons, supports Icons in Clipboard, favorites ...
- Implemented Process Context ID (PCID) feature - Implemented FS/GS BASE access instructions support (according to document from http://software.intel.com/en-us/avx/) - Rewritten from scratch SMC ...
Current Working Directory Section 2.8. Command-Line Arguments Section 2.9. Shell Environment Variables Section 2.10. Standard Streams Section 2.11. File Tools Section 2.12. Directory Tools ...
Hungarian Notation........................55 Variable Naming ..................................................................................................58 It All Begins with WinMain()...
3.4 User Data Manager (Dealing with Player Stats Such as Health, Lives, etc.)....37 3.4.1 Script Breakdown..........................................39 4. Recipes: Common Components 41 4.1 Introduction...
CHAPTER 1 About Python ............................................................................................1 What Is Python? ......................................................................