Debian Codegraph @

templates/eclipse/activities/MasterDetailFlow/root/src/app_package/ContentDetailFragment.java.ftl

raw
1 package ${packageName};
2
3 import android.os.Bundle;
4 import android.<#if appCompat>support.v4.</#if>app.Fragment;
5 import android.view.LayoutInflater;
6 import android.view.View;
7 import android.view.ViewGroup;
8 import android.widget.TextView;
9 <#if applicationPackage??>import ${applicationPackage}.R;</#if>
10
11 import ${packageName}.dummy.DummyContent;
12
13 /**
14 * A fragment representing a single ${objectKind} detail screen.
15 * This fragment is either contained in a {@link ${CollectionName}Activity}
16 * in two-pane mode (on tablets) or a {@link ${DetailName}Activity}
17 * on handsets.
18 */
19 public class ${DetailName}Fragment extends Fragment {
20 /**
21 * The fragment argument representing the item ID that this fragment
22 * represents.
23 */
24 public static final String ARG_ITEM_ID = "item_id";
25
26 /**
27 * The dummy content this fragment is presenting.
28 */
29 private DummyContent.DummyItem mItem;
30
31 /**
32 * Mandatory empty constructor for the fragment manager to instantiate the
33 * fragment (e.g. upon screen orientation changes).
34 */
35 public ${DetailName}Fragment() {
36 }
37
38 @Override
39 public void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
41
42 if (getArguments().containsKey(ARG_ITEM_ID)) {
43 // Load the dummy content specified by the fragment
44 // arguments. In a real-world scenario, use a Loader
45 // to load content from a content provider.
46 mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
47 }
48 }
49
50 @Override
51 public View onCreateView(LayoutInflater inflater, ViewGroup container,
52 Bundle savedInstanceState) {
53 View rootView = inflater.inflate(R.layout.fragment_${detail_name}, container, false);
54
55 // Show the dummy content as text in a TextView.
56 if (mItem != null) {
57 ((TextView) rootView.findViewById(R.id.${detail_name})).setText(mItem.content);
58 }
59
60 return rootView;
61 }
62 }