Skip to content Skip to sidebar Skip to footer

Two Questions About Master/detail Flow Template

I've just taken a look at the Master/Detail Flow template and I can't figure 2 things out. 1) Why does it require Android version 11 when the code it generates seems to use the Fra

Solution 1:

After much looking, the answer is because of this in values-large/refs.xml

<resources>
    <item type="layout" name="activity_item_list">@layout/activity_item_twopane</item>
</resources>

It redirects the request for the normal layout to a larger layout (the two-pane version) where R.id.item_detail_container is defined.

This is pretty obfuscated. I'm not sure why they didn't just call the large layout the same as the normal layout but then have different xml.

Solution 2:

with respect at your first question:

you need change in the class ItemListFragment:

this:

setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
                R.layout.simple_list_item_activated_1,
                R.id.text1,
                DummyContent.ITEMS));

for this:

setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(),
               R.layout.simple_list_item_1,
               R.id.text1,
               DummyContent.ITEMS));

And comment in ItemDetailActivity this line:

// getActionBar().setDisplayHomeAsUpEnabled(true);

Solution 3:

i think the Master/Detail Flow template requires api level 11 because it uses the Action Bar. I will try to use this template with ActionBarSherlcock and see if it works whit android 2.2 or 2.3.

Solution 4:

Regarding the first question, one reason that it requires V11 is that it's using list_content, and that's not included in the compatibility library. A work-around for that is here.

Solution 5:

The technique used in the second part of your question is an example of a Layout Alias.

Post a Comment for "Two Questions About Master/detail Flow Template"