Created
March 7, 2017 04:44
-
-
Save ChandraniChatterjeeMolly/199081930d5013d1cb8e35bc3f1e68cf to your computer and use it in GitHub Desktop.
miwok: MainActivity
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
package com.example.android.miwok; | |
import android.os.Bundle; | |
import android.support.design.widget.TabLayout; | |
import android.support.v4.view.ViewPager; | |
import android.support.v7.app.AppCompatActivity; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Set the content of the activity to use the activity_main.xml layout file | |
setContentView(R.layout.activity_main); | |
// Find the view pager that will allow the user to swipe between fragments | |
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); | |
// Create an adapter that knows which fragment should be shown on each page | |
CategoryAdapter adapter = new CategoryAdapter(this, getSupportFragmentManager()); | |
// Set the adapter onto the view pager | |
viewPager.setAdapter(adapter); | |
// Find the tab layout that shows the tabs | |
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); | |
tabLayout.setupWithViewPager(viewPager); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment