Android Open Source - avol My Array Adapter






From Project

Back to project page avol.

License

The source code is released under:

GNU General Public License

If you think the Android project avol 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 org.keidan.avol.settings;
/*from   w ww .j a v a 2  s  .  co m*/
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

public abstract class MyArrayAdapter<T> extends ArrayAdapter<T> {
  protected Context          c            = null;
  protected int              id           = 0;
  protected List<T>          items        = null;
  
  static class ViewHolder {
    public ImageView   image;
    public TextView    text;
    public CheckBox    check;
  }

  public MyArrayAdapter(final Context context, final int textViewResourceId,
      final List<T> objects) {
    super(context, textViewResourceId, objects);
    c = context;
    id = textViewResourceId;
    items = objects;
  }

  @Override
  public T getItem(final int i) {
    return items.get(i);
  }

  public int getItemCount() {
    return items.size();
  }

  public void addItem(final T t) {
    items.add(t);
    super.notifyDataSetChanged();
  }

  public void removeItem(final T t) {
    items.remove(t);
    super.notifyDataSetChanged();
  }

  public void removeItem(final int i) {
    items.remove(i);
    super.notifyDataSetChanged();
  }
  
  public void clear() {
    items.clear();
    super.clear();
  }

  @Override
  public abstract View getView(final int position, final View convertView,
      final ViewGroup parent);
}




Java Source Code List

org.keidan.avol.ActivityPopup.java
org.keidan.avol.Config.java
org.keidan.avol.SettingsActivity.java
org.keidan.avol.VolActivity.java
org.keidan.avol.main.ComponentsListener.java
org.keidan.avol.main.Components.java
org.keidan.avol.settings.MyArrayAdapter.java
org.keidan.avol.settings.VolumeModel.java
org.keidan.avol.settings.VolumesArrayAdapter.java