Android Open Source - AndroidAdvancedDemos List Fragment






From Project

Back to project page AndroidAdvancedDemos.

License

The source code is released under:

MIT License

If you think the Android project AndroidAdvancedDemos 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.krieger.training.androidadvanceddemos.fragment;
// ww  w.  ja v a  2 s . co  m
import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.essentailab.training.androidadvanceddemos.R;
import com.krieger.training.androidadvanceddemos.adapter.UniversalListAdapter;
import com.krieger.training.androidadvanceddemos.interfaces.AdapterCommand;

@SuppressWarnings("unchecked")
@SuppressLint("ValidFragment")
public class ListFragment extends Fragment{

  private int rowLayoutId;
  private ArrayList<Object> data;
  private AdapterCommand rowInflationAction;
  
  private int headerLayoutId;
  private AdapterCommand headerInflationAction;
  private boolean hasSections = false;
  
  private OnItemClickListener listener;

  public ListFragment(){}
  
  public ListFragment(int rowLayoutId, Object data,
      AdapterCommand rowInflationAction, OnItemClickListener listener){
    this.rowLayoutId= rowLayoutId;
    this.data= (ArrayList<Object>) data;
    this.rowInflationAction= rowInflationAction;
    this.listener= listener;
  }
  
  public ListFragment(int rowLayoutId, int headerLayoutId,
      Object data, AdapterCommand rowInflationAction,
      AdapterCommand headerInflationAction, OnItemClickListener listener){
    this.rowLayoutId= rowLayoutId;
    this.headerLayoutId = headerLayoutId;
    this.headerInflationAction =  headerInflationAction;
    this.data=(ArrayList<Object>) data;
    this.rowInflationAction= rowInflationAction;
    this.listener= listener;
    hasSections = true;
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_list, container, false);
    
    ListView sessionsList = (ListView) v.findViewById(R.id.frag_sessions_lv);
    if(hasSections)
      sessionsList.setAdapter(new UniversalListAdapter(inflater,
          rowLayoutId,
          data,
          rowInflationAction, hasSections,
          headerLayoutId, headerInflationAction));
    else
      sessionsList.setAdapter(new UniversalListAdapter(inflater,
          rowLayoutId,
          data,
          rowInflationAction));
    sessionsList.setOnItemClickListener(listener);
    return v;
  }
}




Java Source Code List

com.krieger.training.androidadvanceddemos.HomeActivity.java
com.krieger.training.androidadvanceddemos.adapter.SimpleListAdapter.java
com.krieger.training.androidadvanceddemos.adapter.UniversalListAdapter.java
com.krieger.training.androidadvanceddemos.entities.DrawerItem.java
com.krieger.training.androidadvanceddemos.entities.HeadedList.java
com.krieger.training.androidadvanceddemos.entities.ImageDownloaderCookie.java
com.krieger.training.androidadvanceddemos.entities.ImageElement.java
com.krieger.training.androidadvanceddemos.entities.ListElementCookie.java
com.krieger.training.androidadvanceddemos.fragment.AsyncTaskFragment.java
com.krieger.training.androidadvanceddemos.fragment.ErrorFragment.java
com.krieger.training.androidadvanceddemos.fragment.GalleryPageFragment.java
com.krieger.training.androidadvanceddemos.fragment.GridViewFragment.java
com.krieger.training.androidadvanceddemos.fragment.ListFragment.java
com.krieger.training.androidadvanceddemos.fragment.NestedFragment.java
com.krieger.training.androidadvanceddemos.fragment.SimpleFragment.java
com.krieger.training.androidadvanceddemos.fragment.ViewPagerFragment.java
com.krieger.training.androidadvanceddemos.interfaces.AdapterCommand.java
com.krieger.training.androidadvanceddemos.interfaces.AsyncListInflationAction.java
com.krieger.training.androidadvanceddemos.interfaces.ListHeaderInflationAction.java
com.krieger.training.androidadvanceddemos.interfaces.ListItemInflationAction.java
com.krieger.training.androidadvanceddemos.io.ImageDownloaderAsyncTask.java
com.krieger.training.androidadvanceddemos.listener.ListOnItemClickListener.java