This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lyla
committed
Mar 4, 2015
1 parent
bd57648
commit e8e638d
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/src/main/java/com/example/android/sunshine/app/DetailActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (C) 2014 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.sunshine.app; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
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(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
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) { | ||
|
||
View rootView = inflater.inflate(R.layout.fragment_detail, container, false); | ||
return rootView; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<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="com.example.android.sunshine.app.DetailActivity" tools:ignore="MergeRootFrame" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<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="com.example.android.sunshine.app.DetailActivity$PlaceholderFragment"> | ||
|
||
<TextView android:text="@string/hello_world" android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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="com.example.android.sunshine.app.DetailActivity"> | ||
<item android:id="@+id/action_settings" android:title="@string/action_settings" | ||
android:orderInCategory="100" app:showAsAction="never" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e8e638d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I created the DetailActivity with the wizard of AndroidStudio 2.2, it created the attribute
in the
<activity>
tag of the DetailActivity in the AndroidManifest.xml. This caused the DetailActivity to have no action bar, and to also hide the system status bar. I had to remove this attribute in order for the DetailActivity to display properly.e8e638d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've just saved my life. thanks 😄