Android Open Source - lists Main Activity






From Project

Back to project page lists.

License

The source code is released under:

GNU General Public License

If you think the Android project lists listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.cs4730.ListDemo;
//from   ww w  . j a  v a2  s  .  c  o m
import java.util.Locale;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;

public class MainActivity extends FragmentActivity {

  String TAG = "MainActivity";

  SectionsPagerAdapter mSectionsPagerAdapter;
  ViewPager mViewPager;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    //mViewPager.setCurrentItem(7);// set to a specific page in the pager.



  }

  /**
   * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
   * one of the sections/tabs/pages.
   */
  public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
      super(fm);
    }

    @Override
    public Fragment getItem(int position) {
      switch (position) {
      case 0: return new Simple_fraglist();
      case 1: return new Simple2_fraglist();
      case 2: return new Simple3_frag();
      case 3: return new Active_fraglist();
      case 4: return new Phone_frag();
      default: return null;
      }
    }

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

    @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);
      case 2:
        return getString(R.string.title_section3).toUpperCase(l);
      case 3:
        return getString(R.string.title_section4).toUpperCase(l);
      case 4:
        return getString(R.string.title_section5).toUpperCase(l);
      }
      return null;
    }
  }  

}




Java Source Code List

edu.cs4730.ListDemo.Active_fraglist.java
edu.cs4730.ListDemo.Active_fraglist.java
edu.cs4730.ListDemo.InteractiveArrayAdapter.java
edu.cs4730.ListDemo.InteractiveArrayAdapter.java
edu.cs4730.ListDemo.MainActivity.java
edu.cs4730.ListDemo.MainActivity.java
edu.cs4730.ListDemo.Model.java
edu.cs4730.ListDemo.Model.java
edu.cs4730.ListDemo.Phone_frag.java
edu.cs4730.ListDemo.Phone_frag.java
edu.cs4730.ListDemo.PhonebookAdapter.java
edu.cs4730.ListDemo.PhonebookAdapter.java
edu.cs4730.ListDemo.Phonebook.java
edu.cs4730.ListDemo.Phonebook.java
edu.cs4730.ListDemo.Simple2_fraglist.java
edu.cs4730.ListDemo.Simple2_fraglist.java
edu.cs4730.ListDemo.Simple3_frag.java
edu.cs4730.ListDemo.Simple3_frag.java
edu.cs4730.ListDemo.Simple_fraglist.java
edu.cs4730.ListDemo.Simple_fraglist.java
edu.cs4730.esplistviewdemo.ExpandableListAdapter.java
edu.cs4730.esplistviewdemo.ExpandableListAdapter.java
edu.cs4730.esplistviewdemo.MainActivity.java
edu.cs4730.esplistviewdemo.MainActivity.java
edu.cs4730.esplistviewdemo.elvDemo1_Fragment.java
edu.cs4730.esplistviewdemo.elvDemo1_Fragment.java
edu.cs4730.esplistviewdemo.elvDemo2_Fragment.java
edu.cs4730.esplistviewdemo.elvDemo2_Fragment.java