Custom ListView Adapter [Android]

后端 未结 2 1849
名媛妹妹
名媛妹妹 2021-01-15 10:58

I\'ve been stuck on a little bug trying to implement a custom listview in Java for an Android application.

I\'m trying to list a bunch words (typically, 100 < n &

2条回答
  •  无人及你
    2021-01-15 11:53

    It turned out the data was different than what I was expecting / thought it was. (Mayra, you were essentially correct).

    Otherwise the original code would have been functioning correctly.

    In the end, the getView(...) class looks like this:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    
        TextView view = (TextView) super.getView(position, convertView, parent);
    
        final String text = (String) view.getText();
    
        if(mHighlightSet.contains(text))
            view.setTextColor(Color.RED);
        else
            view.setTextColor(Color.WHITE);
    
        return view;
    }
    

提交回复
热议问题