Advertisement
Guest User

WebpageDetailFragment.java

a guest
Mar 9th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. package com.example.matthew.masterflow;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v4.app.Fragment;
  5. import android.view.LayoutInflater;
  6. import android.view.View;
  7. import android.view.ViewGroup;
  8. import android.webkit.WebView;
  9.  
  10.  
  11. import com.example.matthew.masterflow.dummy.DummyContent;
  12.  
  13. /**
  14.  * A fragment representing a single Webpage detail screen.
  15.  * This fragment is either contained in a {@link WebpageListActivity}
  16.  * in two-pane mode (on tablets) or a {@link WebpageDetailActivity}
  17.  * on handsets.
  18.  */
  19. public class WebpageDetailFragment 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 WebpageDetailFragment() {
  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_webpage_detail, container, false);
  54.  
  55.         // Show the dummy content as text in a TextView.
  56.         if (mItem != null) {
  57.             ((WebView) rootView.findViewById(R.id.detail_area)).loadUrl(mItem.url);
  58.         }
  59.  
  60.         return rootView;
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement