Skip to content

Instantly share code, notes, and snippets.

@ChandraniChatterjeeMolly
Created March 7, 2017 04:44
Show Gist options
  • Save ChandraniChatterjeeMolly/199081930d5013d1cb8e35bc3f1e68cf to your computer and use it in GitHub Desktop.
Save ChandraniChatterjeeMolly/199081930d5013d1cb8e35bc3f1e68cf to your computer and use it in GitHub Desktop.
miwok: MainActivity
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