5
5
import android .os .Bundle ;
6
6
import android .support .v13 .app .FragmentPagerAdapter ;
7
7
import android .support .v4 .view .ViewPager ;
8
- import android .util .Log ;
9
8
import android .view .*;
10
9
import android .widget .GridView ;
11
10
12
- import java .util .Locale ;
13
-
14
11
public class MainActivity extends Activity implements ActionBar .TabListener {
15
12
16
13
/**
@@ -42,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
42
39
int sections = 4 ;
43
40
// Create the adapter that will return a fragment for each of the three
44
41
// primary sections of the activity.
45
- mSectionsPagerAdapter = new SectionsPagerAdapter (getFragmentManager (), this ,sections );
42
+ mSectionsPagerAdapter = new SectionsPagerAdapter (getFragmentManager (), this , sections );
46
43
47
44
// Set up the ViewPager with the sections adapter.
48
45
mViewPager = (ViewPager ) findViewById (R .id .pager );
@@ -57,8 +54,8 @@ public void onPageSelected(int position) {
57
54
actionBar .setSelectedNavigationItem (position );
58
55
}
59
56
});
60
- String [] sectionNames = {"In Theaters" ,"DVD Releases" ,"Opening" ,"Box Office" };
61
- for (int i = 0 ; i < sections ;i ++) {
57
+ String [] sectionNames = {"In Theaters" , "DVD Releases" , "Opening" , "Box Office" };
58
+ for (int i = 0 ; i < sections ; i ++) {
62
59
actionBar .addTab (actionBar .newTab ().setText (sectionNames [i ]).setTabListener (this ));
63
60
}
64
61
}
@@ -114,7 +111,7 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
114
111
"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?page_limit=24&page=1&country=us&apikey="
115
112
};
116
113
117
- public SectionsPagerAdapter (FragmentManager fm , Context context ,int sections ) {
114
+ public SectionsPagerAdapter (FragmentManager fm , Context context , int sections ) {
118
115
super (fm );
119
116
this .context = context ;
120
117
this .sections = sections ;
@@ -124,8 +121,8 @@ public SectionsPagerAdapter(FragmentManager fm, Context context,int sections) {
124
121
public Fragment getItem (int position ) {
125
122
// getItem is called to instantiate the fragment for the given page.
126
123
// Return a PlaceholderFragment (defined as a static inner class below).
127
- GridAdapter gridAdapter = new GridAdapter (this .context ,LIST [position ]);
128
- return PlaceholderFragment .newInstance (position , context ,gridAdapter );
124
+ GridAdapter gridAdapter = new GridAdapter (this .context , LIST [position ]);
125
+ return PlaceholderFragment .newInstance (position , context , gridAdapter );
129
126
}
130
127
131
128
@ Override
@@ -147,11 +144,12 @@ public static class PlaceholderFragment extends Fragment {
147
144
148
145
private int position ;
149
146
private GridAdapter gridAdapter ;
147
+
150
148
/**
151
149
* Returns a new instance of this fragment for the given section
152
150
* number.
153
151
*/
154
- public static PlaceholderFragment newInstance (int sectionNumber , Context context ,GridAdapter gridAdapter ) {
152
+ public static PlaceholderFragment newInstance (int sectionNumber , Context context , GridAdapter gridAdapter ) {
155
153
PlaceholderFragment fragment = new PlaceholderFragment ();
156
154
Bundle args = new Bundle ();
157
155
args .putInt (ARG_SECTION_NUMBER , sectionNumber );
@@ -168,7 +166,6 @@ public PlaceholderFragment() {
168
166
public View onCreateView (LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) {
169
167
View rootView = inflater .inflate (R .layout .fragment_main , container , false );
170
168
GridView gridview = (GridView ) rootView .findViewById (R .id .gridView );
171
- Log .e (TAG ,"Create view" + position );
172
169
gridview .setAdapter (gridAdapter );
173
170
return rootView ;
174
171
}
0 commit comments