Back to project page digitalcampus.
The source code is released under:
MIT License
If you think the Android project digitalcampus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.llenguatges.digitalcampus.adapters; // w w w. ja va 2 s . co m import java.util.List; import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import com.llenguatges.digitalcampus.R; public class NewSubSyllabusAdapter extends ArrayAdapter<String> { private List<String> elements; private int myLayot; /** * Constructor * @param context * @param data */ public NewSubSyllabusAdapter(Context context, List<String> data) { super(context, android.R.layout.simple_list_item_1); elements = data; this.myLayot = R.layout.new_subject_matter; } /** * Get the data item associated with the specified position in the data set. * @param index * @return data */ public String getItem(int index){ return this.elements.get(index).toString(); } /** * Get how many items are in the data set represented by this Adapter. */ public int getCount(){ return this.elements.size(); } /** * Get a View that displays the data at the specified position in the data set. * @param position * @param converView * @param parent */ public View getView(int pos, View convertView, ViewGroup parent){ View row = convertView; if(row == null){ LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(this.myLayot, parent, false); ImageView imgv = (ImageView) row.findViewById(R.id.new_sub_mtr_discard); imgv.setTag(pos); imgv.setOnClickListener(new OnClickListener() { int pos; @Override public void onClick(View v) { pos = (Integer) v.getTag(); elements.remove(pos); notifyDataSetChanged(); } }); } String a = new String(); a = getItem(pos); int position = pos + 1; TextView text1 = (TextView)row.findViewById(R.id.new_sub_mtr); text1.setText(position+". "+a); text1.setTextColor(Color.BLACK); return row; } }