Example #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            //                Snackbar.make(view, "Replace with your own action",
            // Snackbar.LENGTH_LONG)
            //                        .setAction("Action", null).show();
            Intent intent = new Intent(Home.this, CreateAlarmActivity.class);
            startActivity(intent);
            // For adding animation to activity transition
            overridePendingTransition(R.anim.abc_fade_in, 100000);
          }
        });

    // init alarmList and fill with test data
    AlarmController alarmController = AlarmController.sharedController();
    AlarmController.populateAlarms();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View rootView = inflater.inflate(R.layout.alarms_home, container, false);
    listView = (ListView) rootView.findViewById(R.id.alarm_list);

    // get array of alarms from alarm list
    sharedAlarmList = AlarmController.sharedController().getAlarmList();

    AlarmListAdapter alarmAdapter =
        new AlarmListAdapter(getActivity(), R.layout.alarm_list_item, sharedAlarmList.getAlarms());
    listView.setAdapter(alarmAdapter);

    return rootView;
  }