timmy00274672 / AndroidPractice

Example of Learning Android
4 stars 1 forks source link

Study Adapter Pattern and UI design #5

Open timmy00274672 opened 10 years ago

timmy00274672 commented 10 years ago

Study Adapter Pattern

In TimelineActivity#onResume(), we use

  adapter = new TimelineApdater(this,cursor);  //
  listTimeline.setAdapter(adapter);  //

And TimelineAdapter#bindView(View row,Conext context, Cursor cursor) is where the actual binding of a cursor to view happens.

The question is:

Cursor is the set of result containing many tuples. And in bindView() method, row view should be view of just one tuple. How one tuple binds to one row? Does it create many rows? How are the rows binded to the listTimeline?

timmy00274672 commented 10 years ago

@csyo :question: is updated

timmy00274672 commented 10 years ago

Core idea for adapter is bind presentation layer to the underlying data sources.

Adapter pattern is a design pattern that translates one interface for a class into a compatible interface. 

For example, we use an adapter to translate RS232 to USB.