/**

*
 * 转载请标明出处:http://blog.csdn.net/u013598111/article/details/50519404

*   @author:【JunTao_sun】
 *
 *

时光轴实现

public class MainActivity extends Activity {
private ExpandableListView expandlistView;
private MyExpandAdapter statusAdapter;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
context = this;
expandlistView = (ExpandableListView) findViewById(R.id.expandlist);
initExpandListView();
}
/**
* 初始化
*/
private void initExpandListView() {
statusAdapter = new MyExpandAdapter(context, getListData());
expandlistView.setAdapter(statusAdapter);
// 去掉默认带的箭头
expandlistView.setGroupIndicator(null);
// 设置默认选中项
expandlistView.setSelection(0);
// 遍历所有group,将所有项设置成默认展开
int groupCount = expandlistView.getCount();
for (int i = 0; i < groupCount; i++) {
expandlistView.expandGroup(i);
}
expandlistView.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
return false;
}
});
}
//  @Override
//  public void onBackPressed()
//  {
//      Intent intent = new Intent(Intent.ACTION_MAIN);
//      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//      intent.addCategory(Intent.CATEGORY_HOME);
//      startActivity(intent);
//  }
@Override
public void onBackPressed()
{
//按返回键返回桌面
moveTaskToBack(true);
}
private List<ParentEntity> getListData() {
List<ParentEntity> groupList;
String[] strArray = new String[] { "1月5日", "1月2日","12月25日","12月22日","12月20日"};
String[][] childTimeArray = new String[][] {
{ "去滑雪", "吃火锅", "回到宿舍看电影", "玩微博" },
{ "买牛奶,早早餐","吃土司和面包","吃橘子","出去跑步","看电影" },
{ "送苹果,吃苹果","玩LOL","和朋友聊天","学英语" },
{ "早起哦,买早餐","玩跑跑卡丁车","做午餐","吃螃蟹","睡觉啦" },
{ "出去兜风","准备去买菜","去钓鱼","爬山","回家吃饭辣" }};
groupList = new ArrayList<ParentEntity>();
for (int i = 0; i < strArray.length; i++) {
ParentEntity parentEntity = new ParentEntity();
parentEntity.setGroupName(strArray[i]);
List<ChildEntity> childList = new ArrayList<ChildEntity>();
for (int j = 0; j < childTimeArray[i].length; j++) {
ChildEntity childEntity = new ChildEntity();
childEntity.setDoingSomThing(childTimeArray[i][j]);
childList.add(childEntity);
}
parentEntity.setChildList(childList);
groupList.add(parentEntity);
}
return groupList;
}
}
package com.zihao.adapter;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import com.zihao.R;
import com.zihao.entity.ChildEntity;
import com.zihao.entity.ParentEntity;
public class MyExpandAdapter extends BaseExpandableListAdapter {
private LayoutInflater inflater = null;
private List<ParentEntity> groupList;
/**
* 构造方法
*
* @param context
* @param oneList
*/
public MyExpandAdapter(Context context,
List<ParentEntity> group_list) {
this.groupList = group_list;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/**
* 返回一级Item总数
*/
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return groupList.size();
}
/**
* 返回二级Item总数
*/
@Override
public int getChildrenCount(int groupPosition) {
if (groupList.get(groupPosition).getChildList() == null) {
return 0;
} else {
return groupList.get(groupPosition).getChildList().size();
}
}
/**
* 获取一级Item内容
*/
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return groupList.get(groupPosition);
}
/**
* 获取二级Item内容
*/
@Override
public Object getChild(int groupPosition, int childPosition) {
return groupList.get(groupPosition).getChildList().get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return childPosition;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
GroupViewHolder holder = new GroupViewHolder();
if (convertView == null) {
convertView = inflater.inflate(R.layout.parent_status_item, null);
}
holder.groupName = (TextView) convertView
.findViewById(R.id.one_status_name);
holder.groupName.setText(groupList.get(groupPosition).getGroupName());
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
ChildViewHolder viewHolder = null;
ChildEntity entity = (ChildEntity) getChild(groupPosition,
childPosition);
if (convertView != null) {
viewHolder = (ChildViewHolder) convertView.getTag();
} else {
viewHolder = new ChildViewHolder();
convertView = inflater.inflate(R.layout.child_status_item, null);
viewHolder.dosome = (TextView) convertView
.findViewById(R.id.dosome);
}
viewHolder.dosome.setText(entity.getDoingSomThing());
convertView.setTag(viewHolder);
return convertView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return false;
}
private class GroupViewHolder {
TextView groupName;
}
private class ChildViewHolder {
public TextView dosome;
}
}

两个实体类:

package com.zihao.entity;
/**
* 二级Item实体类
*
* @author zihao
*
*/
public class ChildEntity {
private String dosomething;
public String getDoingSomThing() {
return dosomething;
}
public void setDoingSomThing(String dosomething) {
this.dosomething = dosomething;
}
}
package com.zihao.entity;
import java.util.List;
/**
* 一级Item实体类
*
* @author zihao
*
*/
public class ParentEntity {
private String groupName;
/** 二级Item数据列表 **/
private List<ChildEntity> childList;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public List<ChildEntity> getChildList() {
return childList;
}
public void setChildList(List<ChildEntity> childList) {
this.childList = childList;
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ededed" >
<TextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp"
android:background="#ff00ff00"
android:text="2016年1月4日"
android:textColor="@android:color/black" />
<View
android:id="@+id/top_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/title_text"
android:background="@color/head_line_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/top_line" >
<View
android:id="@+id/group_tiao"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginLeft="55dp"
android:background="@color/time_line_bg" />
<TextView
android:id="@+id/time_axis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="70dp"
android:background="#aa00ff00"
android:text="time axis"
android:textColor="@android:color/white"
android:textSize="20dp" />
<ExpandableListView
android:id="@+id/expandlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/time_axis"
android:cacheColorHint="#00000000"
android:divider="@null" />
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<TextView
android:id="@+id/dosome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="70dp"
android:layout_marginTop="6dp"
android:textColor="#999999" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="5dp"
android:background="@drawable/blue"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/one_status_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#000000"
android:textSize="18sp" />
</LinearLayout>

Android 时光轴 -记录生活相关推荐

  1. 日记背景 android,只是意外 - 用这些 APP 来记录生活,再也不用担心无法坚持写日记 - Android 应用 - 【最美应用】...

    「唉,算了吧,小学那个狂编几十篇日记的开学前夜实在是给我留下了心理阴影--」 喂,朋友,醒醒,这9012年都到了,写日记早就不是你记忆中那个样子了,今天我要安利的这些记录生活的 APP ,或有趣,或简 ...

  2. android iphone 记事本,iPhone上有哪些记事本软件足够你记录生活中的细节?

    iPhone上有哪些记事本软件足够你记录生活中的细节?一款好用的记事本软件应具备启动快.快速添加笔记.运行流畅等元素,所以笔者搜罗了一些优秀的记事本APP,不仅可能实现这些基本要求,还有诸如云同步.跨 ...

  3. 我这里有一款情侣之间用来记录生活的app Android端和web端的

    我这里有一款情侣之间用来记录生活的app app下载地址,复制链接到网页下载即可 web网页端地址 当今社会,情侣之间的交流方式越来越多样化,而一款专门为情侣设计的数据共享应用程序也应运而生.这款应用 ...

  4. 有哪些日记app可以用来记录生活?

    生活中充满了琐碎的细节和美好的瞬间,记录下这些生活点滴,不仅可以让我们回顾过往,还能激发我们对未来的期待和思考.而且在智能化的时代下,我们也可以使用日记app记录生活,不用再随身携带纸笔,但具体用什么 ...

  5. 印象笔记 - 记录生活的点点滴滴

    2012年5月10日,Evernote CEO Phill Libin在GMIC2012演讲中正式宣布推出"印象笔记"服务,同步推出的还有"印象笔记-圈点".& ...

  6. 能用图文记录生活日常的日记APP有哪些推荐?

    为了能全面记录自己成长的轨迹,我们通常会采用记日记的方式来留存回忆,以方便自己能随时查看,而且在现在我们还可以借助手机app记录日记,这样便能达到实时记事.随时查看的目的,既然如此,那么当下有能用图文 ...

  7. 有没有可以记录生活的手机软件?

    我是一个喜欢用文字记录生活的人.因为,在记录生活的过程中,我既可以回忆起那些美好的时刻,又能总结经验教训,进一步完善自己.然而,生活节奏的加快,让我无法经常抽出时间专门坐下来写日记.所以,只好借助手机 ...

  8. 《音乐达人秀:Adobe Audition CC实战222例》——1.3 数字录音记录生活越来越便捷...

    本节书摘来自异步社区<音乐达人秀:Adobe Audition CC实战222例>一书中的第1章,第1.3节,作者 健逗,更多章节内容可以访问云栖社区"异步社区"公众号 ...

  9. 搭建一个专属于两个人的爱情网站,记录生活中的点点滴滴

    搭建一个专属于两个人的爱情网站,记录生活中的点点滴滴 爱情是世界上最为令人着迷的情感,它可以让两个原本毫无关系的人变成最密不可分的伴侣.它可以是山盟海誓也可以是柴米油盐,有些人恋爱喜欢拍照,吃了什么, ...

最新文章

  1. 【C#】第3章学习要点(三)--常用类和结构的用法
  2. Java三大主流开源工作流引擎技术分析
  3. Servlet - HTTP超文本传输协议
  4. C++中局部变量可以和全局变量重名吗?
  5. 全球首发!惯性导航导论(剑桥大学)第八部分
  6. WebLogic下部署war包
  7. 【转】MapReduce读取lzo文件
  8. Centos7 使用 supervisor 管理进程
  9. Struts2学习笔记(4)-ActionSupport类及Action接口详解
  10. 基于友善的superboot 移植linux内核到tiny210(s5pv210)上
  11. 中国语音产业的江湖史
  12. SUPL overview
  13. 关于新版微信电脑版HOOK的技术经验(WX电脑版3.0)
  14. Xray安全评估工具使用
  15. Undefined symbol main (referred from entry9a.o).
  16. TIFF图像文件格式详解(3)
  17. 天线学习笔记——串馈网络设计
  18. 高通WLAN框架学习(17)-- NIO和PNO
  19. 2018:MIXED PRECISION TRAINING OF CONVOLUTIONAL NEURAL NETWORKS USING INTEGER OPERATIONS利用整数运算对卷积神经网络
  20. 人工智能作业之神经网络股票(预测)系统

热门文章

  1. 如何用PPT编制方案 — 1. PPT的总体规划
  2. 高性能服务器架构(High-Performance Server Architecture) .
  3. 阿里云服务器怎么扩容
  4. 09-搜索前端开发-搜索页面
  5. C/C++程序员必看——豆瓣评分9.0+的经典
  6. 品牌管理系统(第一个web项目)
  7. 发票查验|身份证实名认证增强版API开发文档
  8. c++学习笔记(七、异常和I/O)
  9. 西山小菜鸟之Scrapy学习笔记---爬取企查查网站公司基本信息
  10. iOS开发——frame和bounds详解