Skip to content

Commit

Permalink
#59: it has to be a v4 Fragment type
Browse files Browse the repository at this point in the history
  • Loading branch information
fasteque committed Oct 25, 2015
1 parent 1b12766 commit 743b616
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import android.os.Bundle;
import android.app.Fragment;
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
@@ -1,19 +1,16 @@
package com.fastebro.androidrgbtool.ui;

import android.support.design.widget.TabLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.fastebro.androidrgbtool.R;
import com.fastebro.androidrgbtool.fragments.ColorSampleFragment;

public class ColorDetailsActivity extends BaseActivity {

Expand All @@ -36,39 +33,6 @@ protected void onCreate(Bundle savedInstanceState) {
tabLayout.setupWithViewPager(viewPager);
}

/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";

public PlaceholderFragment() {
}

/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_color_details, container, false);
return rootView;
}
}

public class SectionsPagerAdapter extends FragmentPagerAdapter {

public SectionsPagerAdapter(FragmentManager fm) {
Expand All @@ -77,15 +41,13 @@ public SectionsPagerAdapter(FragmentManager fm) {

@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
// TODO: used the static method to get a new instance.
return new ColorSampleFragment();
}

@Override
public int getCount() {
// Show 3 total pages.
return 3;
return 2;
}

@Override
Expand All @@ -95,8 +57,6 @@ public CharSequence getPageTitle(int position) {
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
Expand Down

0 comments on commit 743b616

Please sign in to comment.