Android Open Source - AndroidSectionHeaders Section Headers Sample Activity






From Project

Back to project page AndroidSectionHeaders.

License

The source code is released under:

Apache License

If you think the Android project AndroidSectionHeaders 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 com.marczych.androidsectionheaders.sample;
/*from w ww  .  j a va 2 s .  c  om*/
import java.util.ArrayList;

import com.marczych.androidsectionheaders.*;

import android.app.Activity;
import android.os.Bundle;

public class SectionHeadersSampleActivity extends Activity {
   private SectionListView mListView;
   private SectionHeadersAdapter mAdapter;

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.section_headers);

      mListView = (SectionListView)findViewById(R.id.section_list);
      mAdapter = getSectionAdapter();
      mListView.setAdapter(mAdapter);
      mListView.getListView().setOnItemClickListener(mAdapter);
   }

   private SectionHeadersAdapter getSectionAdapter() {
      SectionHeadersAdapter adapter = new SectionHeadersAdapter();

      for (int i = 0; i < 10; i ++) {
         adapter.addSection(new SampleSectionAdapter(this, getSampleList(),
          "Header #" + i));
      }

      return adapter;
   }

   private ArrayList<String> getSampleList() {
      ArrayList<String> list = new ArrayList<String>();

      for (int i = 0; i < 10; i ++) {
         list.add("List item #" + i);
      }

      return list;
   }
}




Java Source Code List

com.marczych.androidsectionheaders.SectionHeadersAdapter.java
com.marczych.androidsectionheaders.SectionListView.java
com.marczych.androidsectionheaders.Section.java
com.marczych.androidsectionheaders.sample.SampleSectionAdapter.java
com.marczych.androidsectionheaders.sample.SectionHeadersSampleActivity.java