package com.sanrenx.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.sanrenx.entity.OneStatusEntity;
import com.sanrenx.entity.TwoStatusEntity;
import com.sanrenx.main.R;
public class StatusExpandAdapter extends BaseExpandableListAdapter {
//private static final String TAG = "StatusExpandAdapter";
private LayoutInflater inflater = null;
private List<OneStatusEntity> oneList;
private Context context;
public StatusExpandAdapter(Context context, List<OneStatusEntity> oneList) {
this.oneList = oneList;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.context = context;
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return oneList.size();
}
@Override
public int getChildrenCount(int groupPosition) {
if(oneList.get(groupPosition).getTwoList() == null){
return 0;
}else{
return oneList.get(groupPosition).getTwoList().size();
}
}
@Override
public OneStatusEntity getGroup(int groupPosition) {
// TODO Auto-generated method stub
return oneList.get(groupPosition);
}
@Override
public TwoStatusEntity getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return oneList.get(groupPosition).getTwoList().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.one_status_item, null);
}
holder.groupName = (TextView) convertView.findViewById(R.id.one_status_name);
holder.group_tiao = (TextView) convertView.findViewById(R.id.group_tiao);
holder.groupName.setText(oneList.get(groupPosition).getStatusName());
if(oneList.get(groupPosition).getTwoList().get(0).isIsfinished()){
holder.group_tiao.setBackgroundColor(context.getResources().getColor(R.color.yellow));
}else{
holder.group_tiao.setBackgroundColor(context.getResources().getColor(R.color.grey));
}
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
ChildViewHolder viewHolder = null;
TwoStatusEntity entity = getChild(groupPosition, childPosition);
if (convertView != null) {
viewHolder = (ChildViewHolder) convertView.getTag();
} else {
viewHolder = new ChildViewHolder();
convertView = inflater.inflate(R.layout.two_status_item, null);
viewHolder.childName = (TextView) convertView.findViewById(R.id.two_status_name);
viewHolder.twoStatusTime = (TextView) convertView.findViewById(R.id.two_complete_time);
viewHolder.tiao = (TextView) convertView.findViewById(R.id.tiao);
}
viewHolder.childName.setText(entity.getStatusName());
viewHolder.twoStatusTime.setText(entity.getCompleteTime());
if(entity.isIsfinished()){
viewHolder.tiao.setBackgroundColor(context.getResources().getColor(R.color.yellow));
}else{
viewHolder.tiao.setBackgroundColor(context.getResources().getColor(R.color.grey));
}
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;
public TextView group_tiao;
}
private class ChildViewHolder {
public TextView childName;
public TextView twoStatusTime;
public TextView tiao;
}
}
yxkfw
- 粉丝: 82
- 资源: 2万+
最新资源
- 云计算,搭建分布式,然后实现Titantic数据集训练、分类的的代码
- 同城宠物照看-JAVA-基于Spring Boot的同城宠物照看系统的设计与实现(毕业论文)
- 云计算,实现中文字频统计代码,课程设计
- weixin138社区互助养老+ssm(论文+源码)-kaic.zip
- 扶贫助农系统-JAVA-基于spring boot扶贫助农系统设计与实现(毕业论文)
- 母婴护理知识共享-JAVA-基于SpringBoot+vue 的母婴护理知识共享系统(毕业论文)
- 番茄叶片图像病害多标签分类,约5600张数据
- 影音互动科普网站-JAVA-基于SpringBoot的哈利波特书影音互动科普网站设计与实现(毕业论文)
- 航空散货调度-JAVA-基于SpringBoot的航空散货调度系统设计与实现(毕业论文)
- 基于Python Scrapy的贝壳找房爬虫程序
- zigbee CC2530无线自组网协议栈实现一个协调器+多个终端的通讯及控制.zip
- 校园二手物品交易-JAVA-基于springBoot的校园二手物品交易系统的设计与实现(毕业论文)
- 计算机视觉项目:Swin-Transformer 【tiny、small、base】模型实现的图像识别项目:番茄病害图像分类
- 功能完善的电商数据智能爬虫采集系统项目全套技术资料.zip
- 青少年心理健康教育网-JAVA-基于springboot的青少年心理健康教育网站的设计与实现(毕业论文)
- 密评流程及商密应用方案解析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0