- 浏览: 522716 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
c7887qin:
貌似还要使用相同的证书进行签名。。。
Android - 如何将两个/多个应用放到一个进程中去? -
北极光之吻:
天天向上1989 写道不是有OnDoubleTapListen ...
android实现双击事件监听 -
nielong123:
nielong123 写道onCheckedChanged(M ...
Android RadioGroup 换行, 支持多行多列 -
nielong123:
onCheckedChanged(MultiRadioGrou ...
Android RadioGroup 换行, 支持多行多列 -
zk_Ming:
zk_Ming 写道我用了你的,但是radiogroup 点击 ...
Android RadioGroup 换行, 支持多行多列
layout中的main.xml
XML:
<?xml version ="1.0" encoding ="utf-8" ?> <LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android" android:orientation ="vertical" android:layout_width ="fill_parent" android:layout_height ="fill_parent" > <TextView android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:text ="Long-Press on of the Items in the list." /> <ListView android:id ="@+id/list_favorites" android:layout_width ="fill_parent" android:layout_height ="fill_parent" /> </LinearLayout>
源代码是:
Java代码
package com.gggeye.study; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.ContextMenu; import android.view.MenuItem; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnCreateContextMenuListener; import android.widget.ArrayAdapter; import android.widget.ListView; public class ContextMenuSample extends Activity { // =========================================================== // Final Fields // =========================================================== protected static final int CONTEXTMENU_DELETEITEM = 0; // =========================================================== // Fields // =========================================================== protected ListView mFavList; protected ArrayList<Favorite> fakeFavs = new ArrayList<Favorite>(); // =========================================================== // "Constructors" // =========================================================== /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); /* Add some items to the list the listview will be showing. */ fakeFavs.add(new Favorite("John", "nice guy")); fakeFavs.add(new Favorite("Yasmin", "hot girl")); fakeFavs.add(new Favorite("Jack", "cool guy")); this.mFavList = (ListView) this.findViewById(R.id.list_favorites); initListView(); } private void refreshFavListItems() { mFavList.setAdapter(new ArrayAdapter<Favorite>(this, android.R.layout.simple_list_item_1, fakeFavs)); } private void initListView() { /* Loads the items to the ListView. */ refreshFavListItems(); /* Add Context-Menu listener to the ListView. */ mFavList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu conMenu, View view , ContextMenuInfo info) { conMenu.setHeaderTitle("ContextMenu"); conMenu.add(0, 0, 0, "Delete this favorite!"); /* Add as many context-menu-options as you want to. */ } }); } // =========================================================== // Methods from SuperClass/Interfaces // =========================================================== @Override public boolean onContextItemSelected(MenuItem aItem) { ContextMenuInfo menuInfo = (ContextMenuInfo) aItem.getMenuInfo(); /* Switch on the ID of the item, to get what the user selected. */ switch (aItem.getItemId()) { case CONTEXTMENU_DELETEITEM: /* Get the selected item out of the Adapter by its position. */ Favorite favContexted = (Favorite) mFavList.getAdapter() .getItem(0); /* Remove it from the list.*/ fakeFavs.remove(favContexted); refreshFavListItems(); return true; /* true means: "we handled the event". */ } return false; } // =========================================================== // Inner and Anonymous Classes // =========================================================== /** Small class holding some basic */ protected class Favorite { protected String name; protected String kindness; protected Favorite(String name, String kindness) { this.name = name; this.kindness = kindness; } /** The ListView is going to display the toString() return-value! */ public String toString() { return name + " (" + kindness + ")"; } public boolean equals(Object o) { return o instanceof Favorite && ((Favorite) o).name.compareTo(name) == 0; } } }
发表评论
-
Android 修改Android签名证书keystore的密码、别名alias以及别名的密码
2015-04-27 10:35 1165转载请注明出处:http://blog.csdn.net/ ... -
Android签名验证简介
2014-05-16 10:15 5355Android原生自带了个安装器(packages\apps ... -
adb server is out of date. killing...
2014-04-17 10:28 10051:今天调试android的时候发现一个诡异的问题 [htm ... -
Android关闭其他程序
2014-03-21 16:24 15591. restartPackage方法 这个方法在an ... -
正则表达式大全
2014-03-18 17:05 955正则表达式匹配网址: (https://[\w]*.|http ... -
正则表达式大全
2014-03-18 16:53 0正则表达式匹配网址: (https://[\w]*.|http ... -
jni jstring 、char* 类型的转换
2014-03-06 18:20 820jni jstring 、char* 类型的转换 //jst ... -
ListView GridView禁止点击效果
2014-01-12 01:36 5324listView里的item在点击的时候会变成黄色高亮显示,这 ... -
基于 Android NDK 的学习之旅-----资源释放
2014-01-11 14:37 1109转载于http://www.cnblogs.com ... -
Android RadioGroup 换行, 支持多行多列
2013-11-06 16:06 36816经过反复试验,发现无论你怎么摆弄RadioGroup, ... -
Android RadioGroup 换行, 支持多行多列
2013-11-06 16:05 0经过反复试验,发现无论你怎么摆弄RadioGroup, ... -
Android Gallery子元素无法横向填满屏幕的问题解决
2013-07-26 17:50 1430问题解决方法:你只需要把你的子元素的最外层布局用相对 ... -
Android系统手机端抓包方法
2013-06-25 11:42 986抓包准备 1. Android手机需要先获得root权限。 ... -
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{
2013-05-29 15:01 1260出现这个问题时,第一步看看manifest.xml是否配置正确 ... -
Android捕获异常
2013-04-03 14:52 1018如果有些异常是运行时异常,你无法捕获,但是又不想让程序 ... -
root卸载系统程序
2013-02-20 10:31 1685大家知道,卸载程序分为两种。一种是普通的应用程序,一种 ... -
java.lang.IllegalStateException: tried to write 1544 bytes with content-length
2013-01-31 14:57 1399上传文件时,content-length定义的长度小于 ... -
eclipse 开导入android 第三方jar包java heap space问题解决
2013-01-22 17:25 2504最近做android应用需要使用第三方的jar包,结果导入到e ... -
SurfaceView背景设置为透明
2013-01-17 18:41 3393将SurfaceView背景设置为透明,主要添加以下几句话就可 ... -
Android strings.xml中空格符的标识方法附xml特殊字符表示法
2013-01-10 16:03 3168在XML中空格符不是用HMTL中的 表示,而是用 表示。 附X ...
相关推荐
Android之上下文菜单ContextMenu源码
智能家居系统 上下文菜单ContextMenu.doc 学习资料 复习资料 教学资源
android ContextMenu 上下文菜单
1.1 知识解析 1.2 功能演示 1.3 实战操作 1.4 职业素质
ContextMenu 上下文菜单简单使用,文章地址:http://write.blog.csdn.net/postedit/78110175
ContextMenu 上下文选项菜单,长按后跳出菜单.rar
View v,ContextMenu.ContextMenuInfo menuInfo)方法,此方法在每次调出上下文菜单时都会被调用一次,示例中添加了两个文本框,在这个方法中会判断用户单击了哪个文本框,然后定义了菜单项选中状态变化后的回调方法...
ContextMenu 上下文选项菜单,长按后跳出菜单_android源码
NULL 博文链接:https://pop1030123.iteye.com/blog/1125664
安卓Android源码——ContextMenu上下文选项菜单,长按后跳出菜单.zip
ngx-contextmenu, 在任意组件上,为显示上下文菜单的Angular 组件 ngx快捷菜单使用 Angular ( 6 ) 生成的上下文菜单由 ui.bootstrap.contextMenu 激发。 标记中包含 Bootstrap 类,但对 Bootstrap 没有显式依赖关系...
Android应用源码之ContextMenu 上下文选项菜单,长按后跳出菜单_源码
Bootstrap Context Menu是一款非常实用的基于Bootstrap的jQuery右键上下文菜单插件。该右键菜单插件可以在多种元素上触发,也可以配合Font Awesome字体图标一起使用,非常的方便。
主要介绍了Android编程实现为ListView创建上下文菜单(ContextMenu)的方法,简单分析了上下文菜单的功能及ListView创建上下文菜单(ContextMenu)的具体步骤与相关操作技巧,需要的朋友可以参考下
C# ContextMenu,上下文菜单,在窗体正文区点击右键弹出的菜单,支持多层次显示的右键菜单,大多数的窗体都具备类似的菜单效果,在C#中使用这种菜单,也是比较基本的吧,因此本例子对C#初学者来说,可能比较实用吧。
摘要:C#源码,菜单窗体,上下文菜单 ContextMenu——一个C#上下文菜单制作实例源代码,一个小小的C#基础技巧,或许对C#的新手会有不小的帮助。
是JAVA最常见的上下文菜单,在编程中最常遇到,也用了最简单的方式,让人看了一目了然。
jQuery Context Menu - jQuery上下文菜单插件
react使用高德地图react-amap:Map、Markers、Circle、ContextMenu、自定义ContextMenu