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