0

我正在使用固定标题列表视图在列表视图上设置粘性标题,因为我正在使用这个示例。但该示例包含来自适配器的 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数据设置到固定的标题列表视图中,标题是列表的json对象中的“update_ts”,谁能帮我解决这个问题?

4

0 回答 0