Sorin Lascu
Sorin Lascu

Reputation: 405

Working with arrays of android fragments

I'm trying to dissect and work a bit with this example of android fragments. Excuse me for posting links, but the code itself is a bit much and I'm not exactly sure what I should post here.

http://pastebin.com/XKUL0rVz

http://pastebin.com/XW6V2XmG

The layout is pretty straight-forward :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <fragment class="conti.fragments.FragmentLayout$TitlesFragment"
            android:id="@+id/titles" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent" />

    <FrameLayout android:id="@+id/details" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent"
            android:background="?android:attr/detailsElementBackground" />

</LinearLayout>

As far as I can understand, basically a list of all strings from the first array is displayed on the left, when you press on one, it displays the corresponding order text on the right. How can I add a menu item that does something different than display the corresponding text on the right? If I wanted to define its own layout for this new fragment, do I need to modify the layout file or create a new one? Or do I have to create it programatically in the code? I'm a bit confused.

Upvotes: 0

Views: 38

Answers (1)

eurosecom
eurosecom

Reputation: 2992

Create and inflate your own layout at onCreateView

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.your_layout, container, false);


    return view;
}

Upvotes: 1

Related Questions