SHARE
TWEET

Untitled

a guest Jun 16th, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //ADAPTADOR DEL SPINNER DE SEXO
  2.     ArrayAdapter<CharSequence> adapterSexo = ArrayAdapter.createFromResource(this,
  3.             R.array.sexo_array, android.R.layout.simple_spinner_item);
  4.     adapterSexo.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  5.     //ADAPTADOR DEL SPINNER DE EDAD
  6.     List<String> numeros = new ArrayList<String>();
  7.     for (int x = 14; x <= 25; x++) {
  8.         numeros.add(String.valueOf(x));
  9.     }
  10.     //Se le asigna el adaptador al spinner de edad
  11.     edad.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, numeros));
  12.     //Se le asigna el adaptador al spinner de sexo
  13.     sexo.setAdapter(adapterSexo);
  14.      
  15. private void Buscar() {
  16.         AdminSQLiteOpenHelper admin = new AdminSQLiteOpenHelper(this, "baseDatos", null, 1);
  17.         SQLiteDatabase database = admin.getWritableDatabase();
  18.  
  19.         String name = nombre.getText().toString();
  20.  
  21.         if (!name.isEmpty()){
  22.             Cursor row = database.rawQuery("SELECT nombre, domicilio, sexo, edad FROM usuarios WHERE nombre='"+name+"'", null);
  23.             if (row.moveToFirst()){
  24.                 nombre.setText(row.getString(0));
  25.                 domicilio.setText(row.getString(1));
  26. //Se que esta mal de esta manera pero espero haberme dado a entender
  27.                 String x = row.getString(2);
  28.                 sexo.setSelection(Integer.parseInt(x));
  29. //--------------------------------SPINNERS-----------------------------------
  30.                 sexo.setText(row.getString(2));
  31.                 edad.setText(row.getString(3));
  32. //---------------------------------------------------------------------------
  33.                 database.close();
  34.             } else{
  35.                 Toast.makeText(this, "No existe el usuario", Toast.LENGTH_LONG).show();
  36.                 database.close();
  37.             }
  38.         }else{
  39.             Toast.makeText(this, "Favor de introducir un nombre", Toast.LENGTH_LONG).show();
  40.             database.close();
  41.         }
  42.     }`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top