Reputation: 405
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.
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
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