Last active
January 18, 2016 06:59
-
-
Save BALUSANGEM/20693658b76fddfb88c0 to your computer and use it in GitHub Desktop.
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
public class MainActivity extends AppCompatActivity{ | |
SectionsPagerAdapter mSectionsPagerAdapter; | |
static SessioManager session; | |
ViewPager mViewPager; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); | |
// Set up the ViewPager with the sections adapter. | |
mViewPager = (ViewPager) findViewById(R.id.pager); | |
mViewPager.setAdapter(mSectionsPagerAdapter); | |
} | |
public class SectionsPagerAdapter extends FragmentPagerAdapter { | |
public SectionsPagerAdapter(FragmentManager fm) { | |
super(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). | |
switch(position){ | |
case 0: Fragment login = new firstFragment(); | |
return login; | |
case 1: Fragment register = new secondFragment(); | |
return register; | |
default:return null; | |
} | |
} | |
@Override | |
public int getCount() { | |
return 2; | |
} | |
@Override | |
public CharSequence getPageTitle(int position) { | |
Locale l = Locale.getDefault(); | |
switch (position) { | |
case 0: | |
return getString(R.string.title_section1).toUpperCase(l); | |
case 1: | |
return getString(R.string.title_section2).toUpperCase(l); | |
} | |
return null; | |
} | |
} | |
} | |
class firstFragment extends Fragment { | |
View v; | |
@Nullable | |
@Override | |
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { | |
v= inflater.inflate(R.layout.grid_layout,container,false); | |
return v; | |
} | |
} | |
class secondFragment extends Fragment { | |
View v; | |
@Nullable | |
@Override | |
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { | |
v= inflater.inflate(R.layout.grid_layout,container,false); | |
return v; | |
} | |
} | |
//gridlayout.xml File code goes here | |
<RelativeLayout xmlns:tools="http://schemas.android.com/tools" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<GridView | |
android:id="@+id/gridview1" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:columnWidth="50dp" | |
android:gravity="center" | |
android:numColumns="auto_fit" | |
android:stretchMode="columnWidth" > | |
//Put images in gridview here | |
// <Imageview /> | |
// <Imageview /> | |
// <Imageview /> | |
// <Imageview /> | |
// <Imageview /> | |
</GridView> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment