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