Hi all,
I'm trying to develop a fragment that in portrait mode offers the elements in 
a list and in landscape mode offers the elements in a grid.

To implement it, I try this:

*Create two xml files for layouts*

   - res/layout/name_file.xml
   - res/layout-land/name_file.xml

Fragment class

In the method onCreateView()

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_tab, null);
        if (isOnPortraitMode()) {
            list = (ListView) v.findViewById(android.R.id.list);
        } else {
            grid = (GridView) v.findViewById(R.id.gridView);
        }
        return v;
    }

Get list reference or grid reference, depending on the device orientation.
Once I have appropriate reference, in the onActivityCreated() I can 
manipulate it (setAdapter, etc.)

My question is if this way is a good method or are there better.

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to