怎么解析JSON数据后给 ExpandableListView显示
答案:1 悬赏:20 手机版
解决时间 2021-03-05 12:22
- 提问者网友:且恨且铭记
- 2021-03-04 22:22
怎么解析JSON数据后给 ExpandableListView显示
最佳答案
- 五星知识达人网友:傲气稳了全场
- 2021-03-04 22:57
您好,public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
//处理子任务电机的逻辑
return true;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
//子控件布局和数据处理
View view = null;
view = LayoutInflater.from(context).inflate(
R.layout.all_expand_list_item, null);
TextView textView = (TextView) view
.findViewById(R.id.all_list_text_item_id);
textView.setText(chilerd.get(groupPosition).get(childPosition));
return view;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
//父控件布局和数据处理
View view = LayoutInflater.from(context).inflate(
R.layout.all_expand_list, null);
TextView textView = (TextView) view.findViewById(R.id.all_list_text_id);
textView.setText(father.get(groupPosition));
return view;
}
思路有2个,第一种建立一个javabean包含所有json数据参数,利用list添加json字符串,setChildCate的时候在解析一次json数组,再利用另一个list添加数据,这样就有两个适配器了,接下来就好做了,还有一种是分别建立两个javabean 分别解析object和childCatejson数组,道理一样。
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
//处理子任务电机的逻辑
return true;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
//子控件布局和数据处理
View view = null;
view = LayoutInflater.from(context).inflate(
R.layout.all_expand_list_item, null);
TextView textView = (TextView) view
.findViewById(R.id.all_list_text_item_id);
textView.setText(chilerd.get(groupPosition).get(childPosition));
return view;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
//父控件布局和数据处理
View view = LayoutInflater.from(context).inflate(
R.layout.all_expand_list, null);
TextView textView = (TextView) view.findViewById(R.id.all_list_text_id);
textView.setText(father.get(groupPosition));
return view;
}
思路有2个,第一种建立一个javabean包含所有json数据参数,利用list
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯