看起来有两种可能的方法来更改ListView
行中的某些内容:
使用
setViewBinder
/setViewValue
:myCursor.setViewBinder(new 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
:public View getView(int position, View convertView, ViewGroup parent) {
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
这两种方法有什么区别?