为什么当我编写适配器列表视图时,如下所示,列表视图元素随机更改位置?对不起,我糟糕的英语。
private class Adapt2 extends ArrayAdapter {
ArrayList<String> jsonBanks;
public Adapt2(Context context, int textViewResourceId, List objects) {
super(context, textViewResourceId, objects);
jsonBanks = new ArrayList<String>();
jsonBanks.addAll((ArrayList<String>)objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView= vi.inflate(R.layout.main_item, parent,false);
TextView tv = (TextView)convertView.findViewById(R.id.itemText);
tv.setText(jsonBanks.get(position));
}
return convertView;
}
}