Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first draft of view pager demo #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion samples/stock/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
android:icon="@drawable/ic_location_map"
android:label="@string/new_york_city"
android:theme="@style/AppTheme.TranslucentActionBar" />
</application>
<activity
android:name="com.manuelpeinado.fadingactionbar.demo.ViewPagerActivity"
android:icon="@drawable/ic_location_map_dark"
android:label="@string/new_york_city"
android:theme="@style/AppTheme.Light.TranslucentActionBar" />
</application>

</manifest>
12 changes: 12 additions & 0 deletions samples/stock/res/layout/activity_view_pager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</FrameLayout>
1 change: 1 addition & 0 deletions samples/stock/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<string name="activity_title_header_overlay">Header Overlay Example</string>
<string name="choose_city">Choose a city</string>
<string name="action_change_dataset">Change dataset</string>
<string name="activity_title_view_pager">View Pager Example</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class HomeActivity extends ListActivity {
new ActivityInfo(SampleFragmentActivity.class, R.string.activity_title_fragment),
new ActivityInfo(NoParallaxActivity.class, R.string.activity_title_no_parallax),
new ActivityInfo(NavigationDrawerActivity.class, R.string.activity_title_navigation),
new ActivityInfo(HeaderOverlayActivity.class, R.string.activity_title_header_overlay));
new ActivityInfo(HeaderOverlayActivity.class, R.string.activity_title_header_overlay),
new ActivityInfo(ViewPagerActivity.class, R.string.activity_title_view_pager));

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package com.manuelpeinado.fadingactionbar.demo;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.MenuItem;
Expand All @@ -31,7 +31,7 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class NavigationDrawerActivity extends Activity implements AdapterView.OnItemClickListener {
public class NavigationDrawerActivity extends FragmentActivity implements AdapterView.OnItemClickListener {

private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
Expand Down Expand Up @@ -128,7 +128,7 @@ private void selectItem(int position) {
args.putInt(SampleFragment.ARG_ACTION_BG_RES, R.drawable.ab_background);
fragment.setArguments(args);

FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

// update selected item and title, then close the drawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.manuelpeinado.fadingactionbar.demo;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package com.manuelpeinado.fadingactionbar.demo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class SampleFragmentActivity extends Activity {
public class SampleFragmentActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2013 Manuel Peinado
*
* 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.manuelpeinado.fadingactionbar.demo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;

public class ViewPagerActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_pager);

ViewPager viewPager = (ViewPager)findViewById(R.id.viewPager);
viewPager.setAdapter(createViewPagerAdapter());
}

private PagerAdapter createViewPagerAdapter() {
return new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public int getCount() {
return 3;
}

@Override
public Fragment getItem(int position) {
return new SampleFragment();
}
};
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_menu, menu);
return true;
}
}