/ Published in: Java
Adaptador de una lista
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * 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 * */ TextView text1, text2; if (convertView == null) { convertView = mInflater .inflate(R.layout.listview_x, null); convertView.setOnClickListener(new OnClickListener() { onClickRow(position); } }); } else { convertView.setOnClickListener(new OnClickListener() { 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(); } return position; } public long getItemId(int position) { return 0; } }