Android 如何将json数据设置为固定标头listview
我正在使用pinned header listview在我正在使用的列表视图上设置粘性标题。但该示例包含来自适配器的som固定数据,我想设置来自api的数据。我的json数据如下所示Android 如何将json数据设置为固定标头listview,android,json,listview,adapter,pinned-header-list-view,Android,Json,Listview,Adapter,Pinned Header List View,我正在使用pinned header listview在我正在使用的列表视图上设置粘性标题。但该示例包含来自适配器的som固定数据,我想设置来自api的数据。我的json数据如下所示 "diaryEntries": [ { "diaryId": "1", "diaryEntryType": "test", "studentName": "testuser", "diaryText": "Please learn something and
"diaryEntries": [
{
"diaryId": "1",
"diaryEntryType": "test",
"studentName": "testuser",
"diaryText": "Please learn something and come tomorrow",
"authorName": "test author",
"authorRole": "testRole",
"insert_ts": "2017-09-06T08:41:11.000Z",
"update_ts": "2017-09-06T08:41:11.000Z"
},
{
"diaryId": "2",
"diaryEntryType": "test",
"studentName": "testuser1",
"diaryText": "Please learn something and come tomorrow",
"authorName": "test author1",
"authorRole": "testRole1",
"insert_ts": "2017-09-06T08:41:11.000Z",
"update_ts": "2017-09-06T08:41:11.000Z"
}
]
我的适配器代码来自链接示例
public class TestSectionedAdapter extends SectionedBaseAdapter {
@Override
public Object getItem(int section, int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int section, int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getSectionCount() {
return 7;
}
@Override
public int getCountForSection(int section) {
return 15;
}
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
LinearLayout layout = null;
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflator.inflate(R.layout.list_item, null);
} else {
layout = (LinearLayout) convertView;
}
((TextView) layout.findViewById(R.id.textItem)).setText("Section " + section + " Item " + position);
return layout;
}
@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
LinearLayout layout = null;
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflator.inflate(R.layout.header_item, null);
} else {
layout = (LinearLayout) convertView;
}
((TextView) layout.findViewById(R.id.textItem)).setText("Header for section " + section);
return layout;
}
}
如何将json数据设置到pinned header列表视图中,并且标题是列表的json对象中的“update_ts”,有人能帮我解决这个问题吗?是您的响应是json还是GSonresponse在json中?您想做什么?我想将json数据设置到pinned header列表视图中