Android Open Source - CakeUI Cake List View Adapter






From Project

Back to project page CakeUI.

License

The source code is released under:

GNU General Public License

If you think the Android project CakeUI 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.cakeui.generic.adapter;
/*w ww  .j a  va2  s  . c om*/
import java.util.List;

import com.cakeui.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 
 * @author Mariana Azevedo
 * @email mariana@bsi.ufla.br
 * 
 * 
 * Class that implements a generic ListView Adapter.
 *
 */

public class CakeListViewAdapter<T> extends BaseAdapter{

  private Context context;
  private List<T> listViewItems;
  
  public CakeListViewAdapter(Context context, List<T> listViewItems){
    this.context = context;
    this.listViewItems = listViewItems;
  }
  
  @Override
  public int getCount() {
    return listViewItems.size();
  }

  @Override
  public Object getItem(int index) {
    return listViewItems.get(index);
  }

  @Override
  public long getItemId(int position) {
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder viewHolder;
    
    if (convertView == null){
      
      LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.activity_listview_items, parent, false);
      
      viewHolder = new ViewHolder();
      
      viewHolder.itemsContentTextView = (TextView) convertView.findViewById(R.id.listViewItem);
      convertView.setTag(viewHolder);
      
    }else{
      viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.itemsContentTextView.setText(listViewItems.get(position).toString());
    
    return convertView;
  }
  
  static class ViewHolder{
    TextView itemsContentTextView;
  }

}




Java Source Code List

com.cakeui.application.CakeApplication.java
com.cakeui.generic.activity.CakeActivity.java
com.cakeui.generic.adapter.CakeExpandableListViewAdapter.java
com.cakeui.generic.adapter.CakeGridViewAdapter.java
com.cakeui.generic.adapter.CakeListViewAdapter.java
com.cakeui.generic.dialog.CakeDialog.java
com.cakeui.generic.fragment.CakeFragment.java
com.cakeui.generic.service.CakePeriodicService.java
com.cakeui.generic.service.CakeService.java
com.cakeui.utils.CakeAsyncTask.java
com.cakeui.utils.CakeBroadcastReceiver.java
com.cakeui.utils.CakeComparator.java
com.cakeui.utils.CakeDataEncapsulation.java
com.cakeui.utils.CakeMap.java
com.cakeui.utils.enums.AsyncTaskType.java
com.cakeui.utils.enums.DialogType.java
com.cakeui.utils.enums.PagesOpen.java