Android Open Source - grid-view-header Test Adapter






From Project

Back to project page grid-view-header.

License

The source code is released under:

Apache License

If you think the Android project grid-view-header 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.cosic.gridviewheader;
//from   ww  w . ja  va  2  s . c  o  m
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TestAdapter extends BaseAdapter {
  
  Context mContext;
  String[] arr;
  
  public TestAdapter( Context mContext, String[] arr )
  {
    this.mContext = mContext;
    this.arr = arr;
  }
  
  @Override
  public int getCount() {
    // TODO Auto-generated method stub
    return arr.length;
  }

  @Override
  public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
  }

  public class ViewHolder
  {
    public TextView text;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) 
  {
    ViewHolder holder;
    if ( convertView == null )
    {
      //Utilities.log("convert null " + position);
      holder = new ViewHolder();
      convertView = View.inflate(mContext, R.layout.adapter_item, null);
      holder.text = (TextView)convertView.findViewById(R.id.textView1);
      convertView.setTag(holder);
    }else{
      //Utilities.log("convert not null " + position);
      holder = (ViewHolder)convertView.getTag();
    }
    holder.text.setText( arr[position] );

    return convertView;
  }

}




Java Source Code List

com.cosic.gridviewheader.HeaderGridView.java
com.cosic.gridviewheader.TestAdapter.java