qq悬浮列表功能暂未实现

main。xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.Demo9Activity">
<ExpandableListView
android:id="@+id/demo9_expendablelistview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

adapter

public class Demo9Adapter extends BaseExpandableListAdapter {

        private List<String> groupList;//外层的数据源
private List<List<String>> childList;//里层的数据源
private Context context; public Demo9Adapter(Context context, List<String> groupList,List<List<String>> childList ){
this.context = context;
this.groupList = groupList;
this.childList = childList;
} @Override
public int getGroupCount() {
return groupList.size();
} /**
* 这个返回的一定要是对应外层的item里面的List集合的size
* @param groupPosition
* @return
*/
@Override
public int getChildrenCount(int groupPosition) {
return childList.get(groupPosition).size();
} @Override
public Object getGroup(int groupPosition) {
return groupPosition;
} @Override
public Object getChild(int groupPosition, int childPosition) {
return childList.get(groupPosition).get(childPosition);
} @Override
public long getGroupId(int groupPosition) {
return groupPosition;
} @Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
} @Override
public boolean hasStableIds() {
return true;
} @Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
convertView = View.inflate(context, R.layout.item_demo9_style1, null);
//分组名字
TextView textView = (TextView) convertView.findViewById(R.id.group_name);
//子元素的个数
TextView number = (TextView) convertView.findViewById(R.id.count);
number.setText(childList.get(groupPosition).size()+"个");
textView.setText(groupList.get(groupPosition));
return convertView;
} @Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view, ViewGroup viewGroup) {
view = View.inflate(context, R.layout.item_demo9_style2, null);
TextView textView = (TextView) view.findViewById(R.id.child_name);
//外层的分组名字
textView.setText(childList.get(groupPosition).get(childPosition));
return view;
} @Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
} }

main

 private ExpandableListView expandableListView;
private Demo9Adapter myAdapter;
private List<String> groupList;
private List<List<String>> childList; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo9); initView(); }
// 分组悬浮 private void initView() {
expandableListView = (ExpandableListView) findViewById(R.id.demo9_expendablelistview);
groupList = new ArrayList<>();
childList = new ArrayList<>();
addData("幼稚园同学",new String[]{"周杰伦","江一燕 ","佟丽娅","高圆圆","刘诗诗","刘亦菲","angleBaby","张静初","张含韵",});
addData("小学同学",new String[]{"光头强","熊大","熊二","妙蛙种子","比卡丘","双蛋瓦斯","贪吃蛇"});
addData("初中同学",new String[]{"吉泽明步","波多野结衣","爱川美里菜","小川阿佐美","桃谷绘里香","泷泽萝拉","北原多香子","石川施恩惠","北条麻妃","麻仓优","羽田爱","保坂绘里"});
addData("高中同学",new String[]{"秦始皇","李世民","武则天","曹操","刘备","孙权"});
addData("大学同学",new String[]{"周杰伦","江一燕 ","佟丽娅","高圆圆","刘诗诗","刘亦菲","angleBaby","张静初","张含韵",});
addData("研究生同学",new String[]{"光头强","熊大","熊二","妙蛙种子","比卡丘","双蛋瓦斯","贪吃蛇"});
addData("博士同学",new String[]{"小川阿佐美","桃谷绘里香","泷泽萝拉","北原多香子","石川施恩惠","北条麻妃","麻仓优","羽田爱","保坂绘里"});
addData("教授同事",new String[]{"秦始皇","李世民","武则天","曹操","刘备","孙权"});
addData("众仙家名册",new String[]{"苍井空","小泽玛利亚","吉泽明步","波多野结衣","爱川美里菜","小川阿佐美","桃谷绘里香","泷泽萝拉","北原多香子","石川施恩惠","北条麻妃","麻仓优","羽田爱","保坂绘里","秦始皇","李世民","武则天","曹操","刘备","孙权"});
myAdapter = new Demo9Adapter(this,groupList,childList);
expandableListView.setAdapter(myAdapter); // 首次加载全部展开 for (int i = 0; i < groupList.size(); i++) { if(i==0){
expandableListView.collapseGroup(i);
}else {
expandableListView.expandGroup(i);
}
} // 2、不能点击收缩: expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// TODO Auto-generated method stub
return false;
}
}); //长按事件
expandableListView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
menu.setHeaderTitle("选择操作"); // DOWNLOAD_RETRY DOWNLOAD_DEL DOWNLOAD_START
menu.add(0,0 , 0, "重试");
menu.add(0, 1, 0, "删除");
menu.add(0, 2, 0, "启动");
}
}); } /**
* 用来添加数据的方法
*/
private void addData(String group, String[] friend) {
groupList.add(group);
//每一个item打开又是一个不同的list集合
List<String> childitem = new ArrayList<>();
for (int i = 0; i < friend.length; i++) {
childitem.add(friend[i]);
}
childList.add(childitem);
}
/**
* 长按菜单响应函数
*/
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
//关键<span class="wp_keywordlink" style="margin: 0px; padding: 0px; border: 0px; background: transparent;"><a target=_blank href="http://www.xuebuyuan.com/" title="代码" target="_blank" style="text-decoration: none; color: rgb(1, 150, 227);">代码</a></span>
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item.getMenuInfo();
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {//上面的type设定这里类型的判定!这里是child判定!
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); //在child判定里面,获取该child所属group!
int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition); //在child判定里面,获取该child所属position!
switch (item.getItemId()) {
case 0:
Toast.makeText(this,"我是重试",Toast.LENGTH_SHORT).show();
// makeTextShort("我是重试");
break;
case 1:
Toast.makeText(this,"我是删除",Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(this,"我是启动",Toast.LENGTH_SHORT).show();
default:
break;
}
return true;
}
return false;
}

数据参考:http://blog.csdn.net/dl10210950/article/details/52525492

android qq开合表的更多相关文章

  1. 掘金 Android 文章精选合集

    掘金 Android 文章精选合集 掘金官方 关注 2017.07.10 16:42* 字数 175276 阅读 50053评论 13喜欢 669 用两张图告诉你,为什么你的 App 会卡顿? - A ...

  2. 最新最全的 Android 开源项目合集

    原文链接:https://github.com/opendigg/awesome-github-android-ui 在 Github 上做了一个很新的 Android 开发相关开源项目汇总,涉及到 ...

  3. Android 异步开发之 AsyncQueryHandler 批量添加联系人

    AsyncQueryHandler: 官方解释是一个异步帮助类(A helper class to help make handling asynchronous ContentResolver qu ...

  4. Android混合开发之WebViewJavascriptBridge实现JS与java安全交互

    前言: 为了加快开发效率,目前公司一些功能使用H5开发,这里难免会用到Js与Java函数互相调用的问题,这个Android是提供了原生支持的,不过存在安全隐患,今天我们来学习一种安全方式来满足Js与j ...

  5. Android混合开发之WebView与Javascript交互

    前言: 最近公司的App为了加快开发效率选择了一部分功能采用H5开发,从目前市面的大部分App来讲,大致分成Native App.Web App.Hybrid App三种方式,个人觉得目前以Hybri ...

  6. Android混合开发之WebView使用总结

    前言: 今天修改项目中一个有关WebView使用的bug,激起了我总结WebView的动机,今天抽空做个总结. 混合开发相关博客: Android混合开发之WebView使用总结 Android混合开 ...

  7. Android安全开发之ZIP文件目录遍历

    1.ZIP文件目录遍历简介 因为ZIP压缩包文件中允许存在“../”的字符串,攻击者可以利用多个“../”在解压时改变ZIP包中某个文件的存放位置,覆盖掉应用原有的文件.如果被覆盖掉的文件是动态链接s ...

  8. Android驱动开发之Hello实例

    Android驱动开发之Hello实例:   驱动部分 modified:   kernel/arch/arm/configs/msm8909-1gb_w100_hd720p-perf_defconf ...

  9. Android安全开发之WebView中的地雷

    Android安全开发之WebView中的地雷 0X01 About WebView 在Android开发中,经常会使用WebView来实现WEB页面的展示,在Activiry中启动自己的浏览器,或者 ...

随机推荐

  1. Sharepoint 2013 Workflow Error

    问题: (1)提示“reload the page and then start the workflow”错误 (2)提示“Unable to properly communicate with t ...

  2. windows,cmd中进行盘符的切换

    需求描述: 在工作中,有的时候需要在cmd中进行盘符的切换,以前总有些时候 通过cd来切,就是切换不过去,每次都要进行百度查询,所以,这次就记录下, 留着以后再用. 操作过程: 1.通过win+r-& ...

  3. centos7 安装zookeeper 集群

    data 创建myid  设置1 zookeeper默认端口2181  同步端口 20881 和 30881 设置zoo.cfg文件

  4. 【VR】Leap Motion 官网文档 FingerModel (手指模型)

    前言: 感谢关注和支持这个Leap Motion系列翻译的朋友们,非常抱歉因为工作原因非常久没有更新,今后这个翻译还会继续(除非官方直接给出中文文档).本篇献给大家的是 <FingerModel ...

  5. 7 -- Spring的基本用法 -- 3... Spring 的核心机制 : 依赖注入

    7.3 Spring 的核心机制 : 依赖注入 Spring 框架的核心功能有两个. Spring容器作为超级大工厂,负责创建.管理所有的Java对象,这些Java对象被称为Bean. Spring容 ...

  6. swift -- 如何在swift下,使用类似oc的pch文件功能

    以前在做oc下的项目的时候,pch文件是必创建的,因为实在是太方便了,只要在build setting里面把pch的路径换成绝对路径,那么剩下的,想干什么就在里面干什么,但是swift下,可以实现这种 ...

  7. linux命令之用户和用户组

    知识点: 1.-rwx--x--x (711) 只有所有者才有读,写,执行的权限,组群和其他人只有执行的权限 2.将root用户添加到supergroup用户组 groupadd supergroup ...

  8. Linux ulimit 命令

    ulimit命令用来限制系统用户对 shell 资源的访问,常见用法如下: [root@localhost ~]$ ulimit -a # 查看当前所有的资源限制 [root@localhost ~] ...

  9. 初学hadoop,windows下安装

    先bb一下,woc开始使用Cygwin来模拟linux配置hadoop,然后各种错误,找着找着发现原来2.0+的hadoop可以直接在windows下配置.当时真是1w头神兽飞过. 下载hadoop ...

  10. MySQL查询语句练习题

    1.创建student和score表 CREATE  TABLE  student ( id  INT(10)  NOT NULL  UNIQUE  PRIMARY KEY  , name  VARC ...