织梦dedecms程序的文章标题字数限制破解
2016-03-15 15:53
501 查看
本例说明:
QQ,飞信等聊天工具中组后面后会显示有多少个子条目,这个是如何实现的呢?查阅了网上还没有相关的介绍,研究之后,现在本文介绍两种方式实现此功能.
第一种方式:自定义Adapter,重写getGroupView方法.
第二种方式:自定义group.xml中的控件,加一个textview用于显示子条目个数.
注:本文数据库处理使用框架AHibernate,可以灵活操作sqlite数据库,详见: http://blog.csdn.net/lk_blog/article/details/7455992
本文只介绍主要部分,更多细节看上一篇博客:/article/1409647.html
效果图:
第一种方式主要代码:
MyExpListAdapter.java
GroupChildUtil.java:
package com.tgb.lk.demo.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.tgb.lk.expandable.R;
import android.content.Context;
import android.text.TextUtils;
import android.widget.SimpleExpandableListAdapter;
public class GroupChildUtil {
// 组布局文件id
private static int groupLayout = R.layout.list_group;
// 内容布局文件id
private static int childLayout = R.layout.list_child;
// 绑定的组Id的名字
public static String groupIdFrom = "group_id";
// 绑定的组name的名字
public static String groupNameFrom = "group_name";
// 绑定的内容Id的名字
public static String childIdFrom = "child_id";
// 绑定的内容Name的名字
public static String childNameFrom = "child_name";
// 组Id绑定控件Id
private static int groupIdTo = R.id.groupIdTo;
// 内容Id绑定控件的Id
private static int childIdTo = R.id.childIdTo;
// 组名称绑定的控件Id
private static int groupNameTo = R.id.groupNameTo;
// 内容Id绑定的控件Id
private static int childNameTo = R.id.childNameTo;
// 组名称后绑定显示数量的名字
private static String countFrom = "count";
// 组名称后绑定显示数量的Id
private static int countTo = R.id.countTo;
public static SimpleExpandableListAdapter buildAdapter(Context context,
List<GroupChild> groupChildData) {
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
Map<Map<String, String>, List<Map<String, String>>> tempMap = new LinkedHashMap<Map<String, String>, List<Map<String, String>>>();
if (groupChildData != null && groupChildData.size() > 0) {
for (int i = 0; i < groupChildData.size(); i++) {
GroupChild gc = groupChildData.get(i);
Map<String, String> groupMap = new HashMap<String, String>();
Map<String, String> childMap = new HashMap<String, String>();
groupMap.put(groupIdFrom, gc.getGroupId());
groupMap.put(groupNameFrom, gc.getGroupName());
if (TextUtils.isEmpty(gc.getChildId())
&& TextUtils.isEmpty(gc.getChildName())) {
childMap = null;
} else {
childMap.put(childIdFrom, gc.getChildId());
childMap.put(childNameFrom, gc.getChildName());
}
if (tempMap.containsKey(groupMap)) {
if (childMap != null) {
tempMap.get(groupMap).add(childMap);
}
} else {
List<Map<String, String>> tempList = new ArrayList<Map<String, String>>();
if (childMap != null) {
tempList.add(childMap);
}
tempMap.put(groupMap, tempList);
}
}
}
for (Map<String, String> key : tempMap.keySet()) {
List<Map<String, String>> childList = tempMap.get(key);
key.put(countFrom, "("+String.valueOf(childList.size())+")");
groupData.add(key);
childData.add(childList);
}
SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(
context, groupData, groupLayout, new String[] { groupIdFrom,
groupNameFrom, countFrom }, new int[] { groupIdTo,
groupNameTo, countTo }, childData, childLayout,
new String[] { childIdFrom, childNameFrom }, new int[] {
childIdTo, childNameTo });
return sela;
}
}
ExpandableListView实例(一)_数据库增删改查处理和listitem点击长按处理
/article/1409647.html
ExpandableListView实例(二)_两种方式实现QQ中组后面显示子条目数量效果
/article/1409646.html
ExpandableListView实例(三)_实现QQ中"未分组"效果和"未分组"不可编辑删除功能
/article/1409645.html
源代码下载地址:http://download.csdn.net/detail/lk_blog/4299729
QQ,飞信等聊天工具中组后面后会显示有多少个子条目,这个是如何实现的呢?查阅了网上还没有相关的介绍,研究之后,现在本文介绍两种方式实现此功能.
第一种方式:自定义Adapter,重写getGroupView方法.
第二种方式:自定义group.xml中的控件,加一个textview用于显示子条目个数.
注:本文数据库处理使用框架AHibernate,可以灵活操作sqlite数据库,详见: http://blog.csdn.net/lk_blog/article/details/7455992
本文只介绍主要部分,更多细节看上一篇博客:/article/1409647.html
效果图:
第一种方式主要代码:
MyExpListAdapter.java
GroupChildUtil.java修改:
<?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/group" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <TextView android:id="@+id/groupIdTo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> <TextView android:id="@+id/groupNameTo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="10px" android:paddingLeft="30px" android:paddingTop="10px" android:text="No data" android:textSize="26sp" /> <TextView android:id="@+id/countTo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="10px" android:paddingLeft="1px" android:paddingTop="10px" android:textColor="#00ff00" android:textSize="26sp" /> </LinearLayout>
GroupChildUtil.java:
package com.tgb.lk.demo.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.tgb.lk.expandable.R;
import android.content.Context;
import android.text.TextUtils;
import android.widget.SimpleExpandableListAdapter;
public class GroupChildUtil {
// 组布局文件id
private static int groupLayout = R.layout.list_group;
// 内容布局文件id
private static int childLayout = R.layout.list_child;
// 绑定的组Id的名字
public static String groupIdFrom = "group_id";
// 绑定的组name的名字
public static String groupNameFrom = "group_name";
// 绑定的内容Id的名字
public static String childIdFrom = "child_id";
// 绑定的内容Name的名字
public static String childNameFrom = "child_name";
// 组Id绑定控件Id
private static int groupIdTo = R.id.groupIdTo;
// 内容Id绑定控件的Id
private static int childIdTo = R.id.childIdTo;
// 组名称绑定的控件Id
private static int groupNameTo = R.id.groupNameTo;
// 内容Id绑定的控件Id
private static int childNameTo = R.id.childNameTo;
// 组名称后绑定显示数量的名字
private static String countFrom = "count";
// 组名称后绑定显示数量的Id
private static int countTo = R.id.countTo;
public static SimpleExpandableListAdapter buildAdapter(Context context,
List<GroupChild> groupChildData) {
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
Map<Map<String, String>, List<Map<String, String>>> tempMap = new LinkedHashMap<Map<String, String>, List<Map<String, String>>>();
if (groupChildData != null && groupChildData.size() > 0) {
for (int i = 0; i < groupChildData.size(); i++) {
GroupChild gc = groupChildData.get(i);
Map<String, String> groupMap = new HashMap<String, String>();
Map<String, String> childMap = new HashMap<String, String>();
groupMap.put(groupIdFrom, gc.getGroupId());
groupMap.put(groupNameFrom, gc.getGroupName());
if (TextUtils.isEmpty(gc.getChildId())
&& TextUtils.isEmpty(gc.getChildName())) {
childMap = null;
} else {
childMap.put(childIdFrom, gc.getChildId());
childMap.put(childNameFrom, gc.getChildName());
}
if (tempMap.containsKey(groupMap)) {
if (childMap != null) {
tempMap.get(groupMap).add(childMap);
}
} else {
List<Map<String, String>> tempList = new ArrayList<Map<String, String>>();
if (childMap != null) {
tempList.add(childMap);
}
tempMap.put(groupMap, tempList);
}
}
}
for (Map<String, String> key : tempMap.keySet()) {
List<Map<String, String>> childList = tempMap.get(key);
key.put(countFrom, "("+String.valueOf(childList.size())+")");
groupData.add(key);
childData.add(childList);
}
SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(
context, groupData, groupLayout, new String[] { groupIdFrom,
groupNameFrom, countFrom }, new int[] { groupIdTo,
groupNameTo, countTo }, childData, childLayout,
new String[] { childIdFrom, childNameFrom }, new int[] {
childIdTo, childNameTo });
return sela;
}
}
ExpandableListView实例(一)_数据库增删改查处理和listitem点击长按处理
/article/1409647.html
ExpandableListView实例(二)_两种方式实现QQ中组后面显示子条目数量效果
/article/1409646.html
ExpandableListView实例(三)_实现QQ中"未分组"效果和"未分组"不可编辑删除功能
/article/1409645.html
源代码下载地址:http://download.csdn.net/detail/lk_blog/4299729
相关文章推荐
- 找了很久的bug
- phpmailer绑定邮箱
- 获取当前路径
- Linux内核分析(第四周)
- 泼水节ING......丨暹罗猫佛牌
- Android Shape绘制实用圆圈
- android XListView E/AndroidRuntime(7367):at android.widget.HeaderViewListAdapter.isEnabled
- shell【分发系统】
- 20160315 第2章 在窗口中绘图(来自《MFC Windows 程序设计(第2版)》)
- SSL2512&BZOJ1898 沼泽鳄鱼
- 想暂时丢下手头的所有,只和你一起去暹罗看看水灯丨暹罗猫佛牌
- Vc2015 utf8 格式出错
- Android模糊技术
- android scroller类的使用
- HTML小结
- svg性能低?能展现的点比较少?真的是这样吗?
- Vc2015 utf8 unix 格式出错
- 搜索字符串中字符出现的次数,并且高亮显示
- 最简单地实现标签页导航-----TabLayout+ViewPager
- js获取当前页面的URL