Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将json数据设置为固定标头listview_Android_Json_Listview_Adapter_Pinned Header List View - Fatal编程技术网

Android 如何将json数据设置为固定标头listview

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

我正在使用pinned header listview在我正在使用的列表视图上设置粘性标题。但该示例包含来自适配器的som固定数据,我想设置来自api的数据。我的json数据如下所示

"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列表视图中