Android Open Source - list-a-porter List Adapter






From Project

Back to project page list-a-porter.

License

The source code is released under:

Apache License

If you think the Android project list-a-porter 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.android.angelo.listaporter;
/*from  w  w  w  .  java  2  s .c om*/
import java.util.ArrayList;

import com.android.angelo.usedobject.ListItem;

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

public class ListAdapter extends BaseAdapter {

  private class ViewHolder{
    public TextView nome;
    public TextView desc;
    public TextView data;
    public TextView bigD;
  }
  
  ArrayList<ListItem> data;
  Context mContext;
  LayoutInflater mLayoutInflater;
  ViewHolder mViewHolder;
  
  public ListAdapter(Context context, ArrayList<ListItem> data) {
    this.data = data;
    this.mContext = context;
    this.mLayoutInflater = (LayoutInflater) 
        this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  @Override
  public int getCount() {
    return data.size();
  }

  @Override
  public Object getItem(int position) {
    return data.get(position);
  }

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

  @Override
  public View getView(int position, View view, ViewGroup parent) {
    mViewHolder = null;
    if(view == null){
      view = mLayoutInflater.inflate(R.layout.list_item_layout, null);
      mViewHolder = new ViewHolder();
      mViewHolder.nome = (TextView) view.findViewById(R.id.textView_Nome);
      mViewHolder.desc = (TextView) view.findViewById(R.id.textView_Desc);
      mViewHolder.data = (TextView) view.findViewById(R.id.textView_Data);
      mViewHolder.bigD = (TextView) view.findViewById(R.id.textView_BigD);
      view.setTag(mViewHolder);
    }else{
      mViewHolder = (ViewHolder) view.getTag();
    }
    final ListItem item = (ListItem) data.get(position);
    mViewHolder.nome.setText(item.getmName());
    mViewHolder.desc.setText(item.getmDesc());
    mViewHolder.data.setText(item.getmDataString());
    mViewHolder.bigD.setText(item.getmValueString());
    return view;
  }
  
  public void add(Object ob){
    data.add((ListItem)ob);
  }
  
  public void remove(Object ob){
    data.remove(ob);
  }

}




Java Source Code List

com.android.angelo.listaporter.ListAdapter.java
com.android.angelo.listaporter.MainActivity.java
com.android.angelo.listaporter.NotificationService.java
com.android.angelo.listaporter.SettingsActivity.java
com.android.angelo.listaporter.SettingsFragment.java
com.android.angelo.listaporter.ShowItemActivity.java
com.android.angelo.listaporter.ShowItemFragment.java
com.android.angelo.usedobject.DrawerListener.java
com.android.angelo.usedobject.ListItem.java
com.android.angelo.usedobject.UndoBarController.java
com.android.angelo.widget.ListAdaprterLikeGP.java
com.android.angelo.widget.ListAdapter.java