I'm not sure if this is something that depends on the opinions of the developers, but I am creating an Android app and have a Listview view that displays a custom view. My layout basically consists of a view (in the form of an xml resource file and a class obtained from the view that is the root), a domain model object (the data is attached to the view) and an adapter that comes from BaseAdapter that binds the data from the domain model to the view in getViewMethod as follows:
Model: SampleItemUser view: SampleViewAdapter: (code below)
public View getView(int position, View convertView, ViewGroup parent) { SampleView sampleView; SampleItem item = (SampleItem)getItem(position); if(convertView == null) { sampleView = new SampleView(_context); } else { sampleView = (SampleView)convertView; } sampleView.setTitle(item.getTitle()); sampleView.setContentText(item.getContent()); sampleView.setItemRowNumer(item.getRowNumber()); ... //etc return sampleView; }
This is how I always saw it, but I think this is the right way to do it.
, , , , , , , , .
, , , . , , :
public View getView(int position, View convertView, ViewGroup parent) { SampleView sampleView; SampleItem item = (SampleItem)getItem(position); if(convertView == null) { sampleView = new SampleView(_context, item); } else { sampleView = (SampleView)convertView; } return sampleView; }
, , , .
. .
1) CursorAdapter#bindView: . , , Android . , , .
CursorAdapter#bindView
2). AdapterView android - , View, . , / .. . . , AdapterView View , . : Adapter View. View, . , .
AdapterView
View
Adapter
, View , -. , . , , . , , View, , . , .. toString() . , , underling, .
toString()
Source: https://habr.com/ru/post/1786294/More articles:how to get the fully qualified server name and port running in mvc 2 using codebehind - asp.net-mvc-2Android emulator restarts if I try to fix gps coordinates - androidDebugging with zend studio 8 - choosing a local resource - zend-studioРекомендации по архитектуре плагина MVC3 - asp.net-mvcHow to set character used as decimal point in C #? - decimalPython copies and merges linked lists, keeps order - pythonSomeone has problems servicing a hero: on - herokuSyntax for Template Member Functions - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1786298/dot-access-to-static-method&usg=ALkJrhjZWwZSrAFPyfrVZ56TabBW2qcbTAHow to make EF code first run under "IIS AppPool \ MySiteName"? - entity-framework-4All Articles