// criar função para retornar o emelento do array @Override public View getView(int position, View view, ViewGroup parent) { if (view == null) view = getLayoutInflater().inflate(R.layout.listview_item, parent, false); Contact currentContact = Contacts.get(position); TextView name = (TextView) view.findViewById(R.id.contactName); name.setText(currentContact.get_name()); // The below 3 statements are used to update the text to hyperlink // or normal next depending on the state of their checkbox. TextView phone = (TextView) view.findViewById(R.id.phoneNumber); phone.setText(makeLinkOrText(R.id.checkBox, currentContact.get_phone())); TextView email = (TextView) view.findViewById(R.id.emailAddress); email.setText(makeLinkOrText(R.id.checkBox2, currentContact.get_email())); TextView address = (TextView) view.findViewById(R.id.cAddress); address.setText(makeLinkOrText(R.id.checkBox3, currentContact.get_address())); ImageView ivContactImage = (ImageView) view.findViewById(R.id.ivContactImage); ivContactImage.setImageURI(currentContact.get_imageURI()); return view; }
public int updateContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.get_name()); values.put(KEY_PH_NO, contact.get_phone_number()); return db.update( TABLE_CONTACTS, values, KEY_ID + " = ?", new String[] {String.valueOf(contact.get_id())}); }
// CRUD void addContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); // Almacenar los datos (Contact) ContentValues ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.get_name()); values.put(KEY_PH_NO, contact.get_phone_number()); // Insertar Fila SQLite db.insert(TABLE_CONTACTS, null, values); db.close(); // Cierro la conexion }