1 package uk
.me
.njae
.sunshine
;
3 import android
.content
.Intent
;
4 import android
.support
.v7
.app
.ActionBarActivity
;
5 import android
.support
.v7
.app
.ActionBar
;
6 import android
.support
.v4
.app
.Fragment
;
7 import android
.os
.Bundle
;
8 import android
.view
.LayoutInflater
;
9 import android
.view
.Menu
;
10 import android
.view
.MenuItem
;
11 import android
.view
.View
;
12 import android
.view
.ViewGroup
;
13 import android
.os
.Build
;
14 import android
.widget
.TextView
;
16 import uk
.me
.njae
.sunshine
.R
;
18 public class DetailActivity
extends ActionBarActivity
{
21 protected void onCreate(Bundle savedInstanceState
) {
22 super.onCreate(savedInstanceState
);
23 setContentView(R
.layout
.activity_detail
);
24 if (savedInstanceState
== null) {
25 getSupportFragmentManager().beginTransaction()
26 .add(R
.id
.container
, new PlaceholderFragment())
33 public boolean onCreateOptionsMenu(Menu menu
) {
34 // Inflate the menu; this adds items to the action bar if it is present.
35 getMenuInflater().inflate(R
.menu
.detail
, menu
);
40 public boolean onOptionsItemSelected(MenuItem item
) {
41 // Handle action bar item clicks here. The action bar will
42 // automatically handle clicks on the Home/Up button, so long
43 // as you specify a parent activity in AndroidManifest.xml.
44 int id
= item
.getItemId();
45 if (id
== R
.id
.action_settings
) {
48 return super.onOptionsItemSelected(item
);
52 * A placeholder fragment containing a simple view.
54 public static class PlaceholderFragment
extends Fragment
{
56 public PlaceholderFragment() {
60 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
,
61 Bundle savedInstanceState
) {
62 Intent intent
= getActivity().getIntent();
63 View rootView
= inflater
.inflate(R
.layout
.fragment_detail
, container
, false);
64 if (intent
!= null && intent
.hasExtra(Intent
.EXTRA_TEXT
)) {
65 String forecastStr
= intent
.getStringExtra(Intent
.EXTRA_TEXT
);
66 ((TextView
) rootView
.findViewById(R
.id
.detail_text
))
67 .setText(forecastStr
);