Return to Snippet

Revision: 59952
at October 16, 2012 21:29 by ximiboy


Updated Code
/**
 * Adapter of the list X
 * 
 */
public class AdapterListX extends BaseAdapter {
	private LayoutInflater mInflater;
	private ActivityMain c;

        /**
	 * AdapterListX: Constructor
	 * 
	 * @param context
	 */
	public AdapterListX (ActivityMain context) {
		c = context;
		mInflater = LayoutInflater.from(c);
	}

	/**
	 * getView: Inits the view of a row
	 * 
	 */
	public View getView(final int position, View convertView, ViewGroup parent) {
		TextView text1, text2;
		
		if (convertView == null) {
			convertView = mInflater
					.inflate(R.layout.listview_x, null);
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		} else {
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		}

		text1 = (TextView) convertView.findViewById(R.id.Text1);
		text2 = (TextView) convertView.findViewById(R.id.Text2);

		text1.setText("");
		text2.setText("");

		return convertView;
	}

	/**
	 * onClickRow: Controls the event of clicking a row
	 * @param pos
	 */
	private void onClickRow(int pos) {
		notifyDataSetChanged();
	}

	/**
	 * getCount: Gets the number of rows.
	 */
	public int getCount() {
		return cursor.getCount();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return 0;
	}
}

Revision: 59951
at October 12, 2012 05:11 by ximiboy


Updated Code
/**
 * Adapter of the list X
 * 
 */
public class AdapterListX extends BaseAdapter {
	private LayoutInflater mInflater;
	private ActivityMain c;

	public AdapterListX (ActivityMain context) {
		c = context;
		mInflater = LayoutInflater.from(c);
	}

	/**
	 * getView: Inits the view of a row
	 * 
	 */
	public View getView(final int position, View convertView, ViewGroup parent) {
		TextView text1, text2;
		
		if (convertView == null) {
			convertView = mInflater
					.inflate(R.layout.listview_x, null);
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		} else {
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		}

		text1 = (TextView) convertView.findViewById(R.id.Text1);
		text2 = (TextView) convertView.findViewById(R.id.Text2);

		text1.setText("");
		text2.setText("");

		return convertView;
	}

	/**
	 * onClickRow: Controls the event of clicking a row
	 * @param pos
	 */
	private void onClickRow(int pos) {
		notifyDataSetChanged();
	}

	/**
	 * getCount: Gets the number of rows.
	 */
	public int getCount() {
		return cursor.getCount();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return 0;
	}
}

Revision: 59950
at October 11, 2012 22:33 by ximiboy


Initial Code
/**
 * Adapter of the list X
 * 
 */
public class AdapterListX extends BaseAdapter {
	private LayoutInflater mInflater;
	private ActivityMain c;

	public AdapterPedidosAnt(ActivityMain context) {
		c = context;
		mInflater = LayoutInflater.from(c);
	}

	/**
	 * getView: Inits the view of a row
	 * 
	 */
	public View getView(final int position, View convertView, ViewGroup parent) {
		TextView text1, text2;
		
		if (convertView == null) {
			convertView = mInflater
					.inflate(R.layout.listview_x, null);
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		} else {
			convertView.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					onClickRow(position);
				}
			});
		}

		text1 = (TextView) convertView.findViewById(R.id.Text1);
		text2 = (TextView) convertView.findViewById(R.id.Text2);

		text1.setText("");
		text2.setText("");

		return convertView;
	}

	/**
	 * onClickRow: Controls the event of clicking a row
	 * @param pos
	 */
	private void onClickRow(int pos) {
		notifyDataSetChanged();
	}

	/**
	 * getCount: Gets the number of rows.
	 */
	public int getCount() {
		return cursor.getCount();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return 0;
	}
}

Initial URL


Initial Description
Adaptador de una lista

Initial Title
Adapter BaseAdapter

Initial Tags


Initial Language
Java