Guest User

HackFest YorkU App (ItemDetailActivity)

a guest
Feb 26th, 2013
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.64 KB | None | 0 0
  1. package com.example.yulabs;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.jsoup.Jsoup;
  6. import org.jsoup.nodes.Document;
  7. import org.jsoup.nodes.Element;
  8. import org.jsoup.select.Elements;
  9.  
  10. import android.content.Intent;
  11. import android.os.Bundle;
  12. import android.support.v4.app.FragmentActivity;
  13. import android.support.v4.app.NavUtils;
  14. import android.util.Log;
  15. import android.view.MenuItem;
  16.  
  17. /**
  18.  * An activity representing a single Item detail screen. This
  19.  * activity is only used on handset devices. On tablet-size devices,
  20.  * item details are presented side-by-side with a list of items
  21.  * in a {@link ItemListActivity}.
  22.  * <p>
  23.  * This activity is mostly just a 'shell' activity containing nothing
  24.  * more than a {@link ItemDetailFragment}.
  25.  */
  26. public class ItemDetailActivity extends FragmentActivity {
  27.  
  28.     @Override
  29.     protected void onCreate(Bundle savedInstanceState) {
  30.         super.onCreate(savedInstanceState);
  31.         setContentView(R.layout.activity_item_detail);
  32.  
  33.         // Show the Up button in the action bar.
  34.         getActionBar().setDisplayHomeAsUpEnabled(true);
  35.  
  36.         // savedInstanceState is non-null when there is fragment state
  37.         // saved from previous configurations of this activity
  38.         // (e.g. when rotating the screen from portrait to landscape).
  39.         // In this case, the fragment will automatically be re-added
  40.         // to its container so we don't need to manually add it.
  41.         // For more information, see the Fragments API guide at:
  42.         //
  43.         // http://developer.android.com/guide/components/fragments.html
  44.         //
  45.         if (savedInstanceState == null) {
  46.             // Create the detail fragment and add it to the activity
  47.             // using a fragment transaction.
  48.             Bundle arguments = new Bundle();
  49.             arguments.putString(ItemDetailFragment.ARG_ITEM_ID,
  50.                     getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
  51.             ItemDetailFragment fragment = new ItemDetailFragment();
  52.             fragment.setArguments(arguments);
  53.             getSupportFragmentManager().beginTransaction()
  54.             .add(R.id.item_detail_container, fragment)
  55.             .commit();
  56.         }
  57.     }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.     @Override
  64.     public boolean onOptionsItemSelected(MenuItem item) {
  65.         switch (item.getItemId()) {
  66.         case android.R.id.home:
  67.             // This ID represents the Home or Up button. In the case of this
  68.             // activity, the Up button is shown. Use NavUtils to allow users
  69.             // to navigate up one level in the application structure. For
  70.             // more details, see the Navigation pattern on Android Design:
  71.             //
  72.             // http://developer.android.com/design/patterns/navigation.html#up-vs-back
  73.             //
  74.             NavUtils.navigateUpTo(this, new Intent(this, ItemListActivity.class));
  75.             return true;
  76.         }
  77.         return super.onOptionsItemSelected(item);
  78.     }
  79. }
Add Comment
Please, Sign In to add comment