46、微信-群聊列表
仍然使用通用布局 activity_listview,不过添加了一个列表头:
View layout_head = getLayoutInflater().inflate(R.layout.layout_head_search, null);mlistview.addHeaderView(layout_head);
用于搜索。
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="vertical"> <TextViewandroid:id="@+id/txt_search"android:layout_width="fill_parent"android:layout_height="33dp"android:drawableLeft="@drawable/search_icon"android:background="@drawable/search_ba"android:layout_margin="15dp"android:paddingLeft="20dp"android:text="@string/search"android:drawablePadding="10dp"android:textColor="@color/black1"android:gravity="center|left"android:singleLine="true" /> </LinearLayout>
通过服务器获取群聊列表:
@Overrideprotected void initView() {try { List<EMGroup> grouplist = EMGroupManager.getInstance().getGroupsFromServer();if (grouplist != null && grouplist.size() > 0) {mlistview.setAdapter(new MyGroupAdpter(this, grouplist)); } else { TextView txt_nodata = (TextView) findViewById(R.id.txt_nochat); txt_nodata.setText("暂时没有群聊"); txt_nodata.setVisibility(View.VISIBLE); } } catch (EaseMobException e) { e.printStackTrace(); }}
群聊适配器:
public class MyGroupAdpter extends BaseAdapter {protected Context context;private List<EMGroup> grouplist; public MyGroupAdpter(Context ctx, List<EMGroup> grouplist) {context = ctx;this.grouplist = grouplist; } @Overridepublic int getCount() {return grouplist.size(); } @Overridepublic Object getItem(int position) {return null; } @Overridepublic long getItemId(int position) {return position; } @Overridepublic View getView(int position, View convertView, ViewGroup parent) {if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_mygroup, parent, false); }final EMGroup group = grouplist.get(position); ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo); TextView txt_name = ViewHolder.get(convertView, R.id.txt_name); img_avar.setImageResource(R.drawable.defult_group); txt_name.setText(group.getGroupName()); convertView.setOnClickListener(new View.OnClickListener() { @Overridepublic void onClick(View v) { Intent intent = new Intent(context, ChatActivity.class); intent.putExtra(Constants.NAME, group.getGroupName()); intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP); intent.putExtra(Constants.GROUP_ID, group.getGroupId());context.startActivity(intent); } });return convertView; }}
子项布局文件:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="vertical"> <RelativeLayoutandroid:layout_width="match_parent"android:layout_height="60.0dip"android:background="@drawable/setting_item_selector"android:paddingLeft="10dip"> <ImageViewandroid:id="@+id/img_photo"android:layout_width="45dip"android:layout_height="45dip"android:layout_centerVertical="true"android:src="@drawable/head" /> <TextViewandroid:id="@+id/txt_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="车友群"android:textSize="18sp" android:layout_centerVertical="true"android:layout_toRightOf="@+id/img_photo"android:layout_marginLeft="13dp"android:singleLine="true" /> </RelativeLayout> <Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/black2" /> </LinearLayout>
46、微信-群聊列表相关推荐
- 个人微信api接口调用,推送微信好友群聊列表及返回
个人微信api接口调用,推送微信好友群聊列表及返回 触发手机推送微信好友列表及返回/*** 触发手机推送微信好友列表* @author wechatno:tangjinjinwx* @blog htt ...
- 环信群列表 php,一行代码实现群聊头像(用环信仿微信群聊头像)
做这个环信群聊头像的时候,我在考虑怎么自定义,怎么去拼接这个群聊头像,怎么获取群成员的头像,怎么在群成员退出群聊的时候更新头像,,, 群聊的东西真的很多,最近刚刚弄完群聊头像,并没有考虑到退出的时候怎 ...
- 从小程序快速扫码进微信群聊
众所周知,由于各种原因,从小程序里面是无法直接识别二维码的,可能有别的路子可以间接实现,比如利用客服消息推送,但这不是长久之计,也不是官方支持的,可能会影响审核.今天说的方法,是官方开放的功能,可以放 ...
- 使用伪类来实现类似微信群聊的头像样式
最近看了一篇张鑫旭的博客,觉得人家的想法特别奇特,很值得学习.遂借鉴学习并记录一下,以备不时之需. 原文地址:伪类匹配列表数目实现微信群头像CSS布局的技巧 简介 我们在使用微信群聊的时候,群聊的头像 ...
- 《OnlineChat996》基于微信群聊的在线实时通信工具
项目源码:你和我的畅聊时光 一.主要功能 注册,成为我们的注册会员用户,你将拥有全网唯一的ID. 登录,进入拥有千万好友的畅聊空间. 私聊,你可以选择和任意在线用户进行一次亲密对话. 群聊,只要你想, ...
- android微信群聊功能,微信安卓内测更新,这个群聊功能等了8年
近日,安卓版微信悄然迎来了 8.0.3 内测版更新,本次内测又带来了哪些新功能呢,一起来看看吧. 01 群聊支持键入 @所有人 微信作为国民级应用,而微信群又是微信中的一个重要组成部分." ...
- python开发微信群_Python编程:微信群聊程序的开发与进/线程知识汇总(附代码)
本文承接上篇文章的客户端-服务器聊天对话程序,进一步设计开发了微信群聊的python模拟程序,涉及的python知识点为:Python实战:聊天软件开发与TCP/Socket编程知识汇总(附代码)和 ...
- 用 Python 分析微信群聊记录,是怎样一种体验?
1. 场景 前几天,有一位小伙伴在后台给我留言,说自己有几十个微信群,自己精力有限,没法看过来,想要筛选一些高质量的群,让我是否能帮忙想想办法. 其实,微信群里的所有聊天记录都在手机本地文件夹内,只需 ...
- 极客日报:字节员工操纵抖音热榜被判刑;微信群聊可直接访问电商外链;JetBrains发布新一代编辑器Fleet
一分钟速览新闻点! 中国互联网企业综合实力指数(2021)发布:BAT仍列前三 微信群聊可直接访问电商外链 消息称美团智慧交通平台拆分,打车事业部独立 字节员工操纵抖音热榜被判刑 苹果再成为中国最大智 ...
最新文章
- 1112. Stucked Keyboard (20)
- 链表问题14——在单链表种删除指定值的节点
- vi 命令linux退不出来,Linux 基本命令 vi的退出方法
- Android 4.4 Kitkat 使能有线网络 Ethernet
- 无基础人员转行做机器学习可以吗?
- static and const
- Linux系统有线网络抓包程序
- ES和Kibana在docker中的安装
- ES terms多值搜索及范围过滤深入剖析-搜索系统线上实战
- Expression Blend中文教程 - 开篇
- 自由职业者互联网进化记
- linux卸载jdk方法
- 小学听力测试英语软件,亲测:好用的小学英语软件有哪些?这6款通通安利给大家!...
- 《人类简史》笔记——认知革命和农业革命背后的思考
- linux查看硬盘插槽_SSD小讲堂丨自己动手丰衣足食 手把手教你安装M.2固态硬盘
- python微信投票平台_Python——开发一个自动化微信投票器【附代码实例方法】
- 【Spring Security】spring security 之初探jwt
- [Crypto]ECB模式攻击
- 人民币符号怎么打?美元符号怎么打?
- 根据公式计算圆周率Π的值