阿尔戈利亚自定义适配器搜索

时间:2020-02-19 13:37:08

标签: android

我已在我的adroid应用程序上实现了Algolia Search,它运行良好,但结果显示在ArrayAdapter中,我想在“自定义布局”中显示结果,我使用适配器创建了自定义布局,但未显示任何内容

这是我的旧适配器:

ArrayAdapter<String> arrayAdapter2 = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1, listJobss);

这是我的新适配器:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View cell = convertView;
    if (cell == null) {
    cell = LayoutInflater.from(context).inflate(R.layout.algolia_item, parent, false);
    TextView companyName =  cell.findViewById(R.id.algolia_companyname);
    TextView contractType =  cell.findViewById(R.id.algolia_contracttype);
    TextView jobname =  cell.findViewById(R.id.algolia_jobname);

    HighlightedResult<algoliaData> result = getItem(position);

    companyName.setText(highlightRenderer.renderHighlights(result.getHighlight("CompanyName").getHighlightedValue()));
    jobname.setText(String.format("%d", result.getResult().getJobName()));
    contractType.setText(String.format("%d", result.getResult().getContractType()));

    return cell;
}

@Override
public void addAll(Collection<? extends HighlightedResult<algoliaData>> items) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        super.addAll(items);
    } else {
        for (HighlightedResult<algoliaData> item : items) {
            add(item);
        }
    notifyDataSetChanged();
    }
}

我想知道如何解决此问题?

0 个答案:

没有答案