How many Activities vs Fragments?

后端 未结 5 620
情深已故
情深已故 2020-11-30 16:34

Intro:

The basic \"Fragments Tutorial\" pattern goes something like this:

  1. On a tablet, have a list on the left, details on the right.
  2. Both
5条回答
  •  感情败类
    2020-11-30 16:49

    One problem with this method, is that you duplicate a lot of the logic in the main Tablet Activity, and in the separate Phone Activities.

    In the master-detail pattern, there are two activities. One shows both fragments on larger screens and only the "master" fragment on smaller screens. The other shows the "detail" fragment on smaller screens.

    Your detail logic should be tied up in the detail fragment. Hence, there is no code duplication related to detail logic between activities -- the detail activity merely displays the detail fragment, perhaps passing in data from an Intent extra.

    Also what I have read about the ActionBarSherlock is that it seems to work best with Fragments instead of Activities (but I have not worked with it yet).

    ActionBarSherlock has no more to do with fragments than does the native action bar, since ActionBarSherlock is purely a backport of the native action bar.

提交回复
热议问题