数组适配器的getView函数中位置属性的意义是什么?我遇到了一个例子,其中getView被一次又一次地调用,值为0,而传递给它的列表有多个元素。请帮忙
private ArrayAdapter<Connection> buildConnectionAdapter(final ArrayList<Connection> connectionList) {
ArrayAdapter<Connection> attachmentadapter = new ArrayAdapter<Connection>(this, R.layout.text_view, R.id.dummy, connectionList) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final String value;
Connection obj = connectionList.get(position);
value = obj.getValue();
TextView tv = new TextView(UserGlobalAppSettings.this);
SpannableString str = makeLinkSpan(value, new OnClickListener() {
@Override
public void onClick(View v) {
}
});
str.setSpan(new URLSpan(""), 0, value.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
tv.setText(str);
tv.setTag(obj);
return tv;
}
};
return attachmentadapter;
}
布局是这样的
<ListView
android:id="@+id/im_services_list"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
</ListView>