Android 从应用框架角度看ListView与Adapter类别
2010-06-01 15:48:00 来源:WEB开发网核心提示:coll.add("Hello!!");coll.add("Exit");}public int getCount() {return coll.size();}public Object getItem(int position) {return coll.get(positi
coll.add("Hello!!");
coll.add("Exit");
}
public int getCount() {
return coll.size();
}
public Object getItem(int position) {
return coll.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv;
if (convertView == null)
tv = new TextView(ctx);
else
tv = (TextView)convertView;
tv.setTextColor(Color.CYAN);
tv.setHeight(45);
tv.setTextSize(26);
tv.setText(coll.get(position));
return tv;
}
}
其于,这样的基本结构,就能进一步发展出各式各样的Adapter了。例如ArrayAdapter、SimpleAdapter等等。于此,只节录讲义的前段基础部份,至于后段的应用部分,就省略之。
更多精彩
赞助商链接