Assign an element [name] of the database that is in a list to an EditText

0
nome = (EditText) findViewById(R.id.edt_nomecli);

listaclientes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {                   
        Integer cod = i;
        Cursor cursor = banco.rawQuery("SELECT nome FROM clientes WHERE id_cli = '"+cod+"' ",null);
        if(cursor!=null)
        {  
            int cnome=cursor.getColumnIndex("nome");
            nome.setText(cursor.getString(cnome), TextView.BufferType.EDITABLE);
        }  
    }  
});

The ERROR IS TIME TO IMPLEMENT.

    
asked by anonymous 16.02.2018 / 18:17

1 answer

0

I was able to resolve ...

nome = (EditText) findViewById(R.id.edt_nomecli);

listaclientes.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {                   
    final Integer j = i;
      String n = adapternome.getItem(j).toString();
        try {
            Cursor cursor = banco.rawQuery("SELECT * FROM clientes WHERE nome = '" + n +"'", null);
            int colunaN = cursor2.getColumnIndex("nome");
            cursor.moveToFirst();
            while (cursor != null)
           {
             nome.setText(cursor.getString(colunaN), TextView.BufferType.EDITABLE);
             abas.setCurrentTab(1);
             cursor.moveToNext();
            }
       }catch (Exception E ){E.printStackTrace();}
    }  
});
    
16.04.2018 / 18:51