Android Open Source - AbstractGroupedAdapter My Adapter






From Project

Back to project page AbstractGroupedAdapter.

License

The source code is released under:

Copyright (c) 2013 Aryan Ghassemi. All rights reserved. https://github.com/aryaxt/AbstractGroupedAdapter Permission is hereby granted, free of charge, to any person obtaining a copy of this software...

If you think the Android project AbstractGroupedAdapter 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.aryaxt.groupedadapter;
//from  w ww  . j  a v  a  2 s . c  o m
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class MyAdapter extends AbstractGroupedAdapter<String, Person> {

  public MyAdapter(Context context) {
    super(context);
  }
  
  @Override
  public View getView(int position, View view, ViewGroup parent) {
  
    if (this.isItemHeader(position)) {
      String header = this.getHeader(position);
      
      view = getReusableView(view, R.layout.header);
      TextView textView = (TextView) view.findViewById(R.id.txtHeaderTitle);
      textView.setText(header);
    }
    else {
      Person person = this.getItem(position);
      
      view = getReusableView(view, R.layout.row);
      TextView textView = (TextView) view.findViewById(R.id.txtPersonName);
      textView.setText(person.getName());
    }

    return view;
  }
}




Java Source Code List

com.aryaxt.groupedadapter.AbstractGroupedAdapter.java
com.aryaxt.groupedadapter.MainActivity.java
com.aryaxt.groupedadapter.MyAdapter.java
com.aryaxt.groupedadapter.Person.java