textView.setText 将列表中的所有项目设置为同一事物。如何从我的 ArrayList 创建一个包含所有元素的列表?我需要以某种方式指定位置吗?
public class CustomAdapter extends BaseAdapter {
private Context ctx;
private ArrayList<String> children;
CustomAdapter (ArrayList<String> data, Context context, String log) {
this.ctx = context;
this.children = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
LayoutInflater inflator = (LayoutInflater)ctx.getSystemService(LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(R.layout.text_list, null);
TextView textView = (TextView) v.findViewById(R.id.logText);
System.out.println("Cyan");
textView.setTextColor(Color.CYAN);
System.out.println("LOG SIZE: " + log.size());
for(int i = 0; i < children.size(); i++){
textView.setText(children.get(i));
}
return textView;
}
@Override
public int getCount() {
return children.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
}
}