3
看起來有兩種可能的方式來改變的東西在ListView
行:setViewBinder/setViewValue和getView/LayoutInflater的用法有什麼區別?
使用
setViewBinder
/setViewValue
:myCursor.setViewBinder(新SimpleCursorAdapter.ViewBinder(){
@Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { int viewId = view.getId(); switch(viewId) { case R.id.icon: // change something related to the icon here
使用
getView
/LayoutInflater
:公共查看getView(INT位置,查看convertView,ViewGroup以及母公司){
View itemView = null; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); itemView = inflater.inflate(R.layout.list_row, null); } else { itemView = convertView; } ImageView imgViewChecked = (ImageView) itemView .findViewById(R.id.icon); // change something related to the icon here
的是這兩種方法之間的區別?