<component name="libraryTable">
<library name="appcompat-v7-19.1.0">
<CLASSES>
- <root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" />
- <root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" />
+ <root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" />
+ <root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity
+ android:name=".DetailActivity"
+ android:label="@string/title_activity_detail"
+ android:parentActivityName=".MainActivity" >
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value="uk.me.njae.sunshine.MainActivity" />
+ </activity>
</application>
</manifest>
--- /dev/null
+package uk.me.njae.sunshine;
+
+import android.content.Intent;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.ActionBar;
+import android.support.v4.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.os.Build;
+import android.widget.TextView;
+
+import uk.me.njae.sunshine.R;
+
+public class DetailActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_detail);
+ if (savedInstanceState == null) {
+ getSupportFragmentManager().beginTransaction()
+ .add(R.id.container, new PlaceholderFragment())
+ .commit();
+ }
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.detail, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+ if (id == R.id.action_settings) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * A placeholder fragment containing a simple view.
+ */
+ public static class PlaceholderFragment extends Fragment {
+
+ public PlaceholderFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ Intent intent = getActivity().getIntent();
+ View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
+ if (intent != null && intent.hasExtra(Intent.EXTRA_TEXT)) {
+ String forecastStr = intent.getStringExtra(Intent.EXTRA_TEXT);
+ ((TextView) rootView.findViewById(R.id.detail_text))
+ .setText(forecastStr);
+ }
+ return rootView;
+ }
+ }
+}
package uk.me.njae.sunshine;
+import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
- ListView list_view = (ListView) rootView.findViewById(R.id.listview_forecast);
- list_view.setAdapter(mForecastAdapter);
+ ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
+ listView.setAdapter(mForecastAdapter);
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
+ String forecast = mForecastAdapter.getItem(position);
+ Intent intent = new Intent(getActivity(), DetailActivity.class)
+ .putExtra(Intent.EXTRA_TEXT, forecast);
+ startActivity(intent);
+ }
+ });
return rootView;
}
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="uk.me.njae.sunshine.DetailActivity"
+ tools:ignore="MergeRootFrame" />
--- /dev/null
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ tools:context="uk.me.njae.sunshine.DetailActivity$PlaceholderFragment">
+
+ <TextView
+ android:id="@+id/detail_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
--- /dev/null
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="uk.me.njae.sunshine.DetailActivity" >
+ <item android:id="@+id/action_settings"
+ android:title="@string/action_settings"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+</menu>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="action_refresh">Refresh</string>
+ <string name="title_activity_detail">DetailActivity</string>
</resources>